forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 83
/
content.go
54 lines (44 loc) · 1.38 KB
/
content.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2017 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package scm
import "context"
type (
// Content stores the contents of a repository file.
Content struct {
Path string
Data []byte
Sha string
}
// ContentParams provide parameters for creating and
// updating repository content.
ContentParams struct {
Ref string
Branch string
Message string
Data []byte
Sha string
}
// FileEntry returns the details of a file
FileEntry struct {
Name string
Path string
Type string
Size int
Sha string
Link string
}
// ContentService provides access to repositroy content.
ContentService interface {
// Find returns the repository file content by path.
Find(ctx context.Context, repo, path, ref string) (*Content, *Response, error)
// Lists the files or directories at the given path
List(ctx context.Context, repo, path, ref string) ([]*FileEntry, *Response, error)
// Create creates a new repository file.
Create(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
// Update updates a repository file.
Update(ctx context.Context, repo, path string, params *ContentParams) (*Response, error)
// Delete deletes a reository file.
Delete(ctx context.Context, repo, path, ref string) (*Response, error)
}
)