-
Notifications
You must be signed in to change notification settings - Fork 237
/
repo.go
152 lines (127 loc) · 4.07 KB
/
repo.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// 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"
"time"
)
type (
// Repository represents a git repository.
Repository struct {
ID string
Namespace string
Name string
Perm *Perm
Branch string
Archived bool
Private bool
Visibility Visibility
Clone string
CloneSSH string
Link string
Created time.Time
Updated time.Time
}
// Perm represents a user's repository permissions.
Perm struct {
Pull bool
Push bool
Admin bool
}
// Hook represents a repository hook.
Hook struct {
ID string
Name string
Target string
Events []string
Active bool
SkipVerify bool
}
// HookInput provides the input fields required for
// creating or updating repository webhooks.
HookInput struct {
Name string
Target string
Secret string
Events HookEvents
SkipVerify bool
// NativeEvents are used to create hooks with
// provider-specific event types that cannot be
// abstracted or represented in HookEvents.
NativeEvents []string
}
// HookEvents represents supported hook events.
HookEvents struct {
Branch bool
Deployment bool
Issue bool
IssueComment bool
PullRequest bool
PullRequestComment bool
Push bool
ReviewComment bool
Tag bool
}
// Status represents a commit status.
Status struct {
State State
Label string
Desc string
Target string
// TODO(bradrydzewski) this field is only used
// by Bitbucket which requires a user-defined
// key (label), title and description. We need
// to cleanup this abstraction.
Title string
}
// StatusInput provides the input fields required for
// creating or updating commit statuses.
StatusInput struct {
State State
Label string
Title string
Desc string
Target string
}
// DeployStatus represents a deployment status.
DeployStatus struct {
Number int64
State State
Desc string
Target string
Environment string
EnvironmentURL string
}
// RepositoryService provides access to repository resources.
RepositoryService interface {
// Find returns a repository by name.
Find(context.Context, string) (*Repository, *Response, error)
// FindHook returns a repository hook.
FindHook(context.Context, string, string) (*Hook, *Response, error)
// FindPerms returns repository permissions.
FindPerms(context.Context, string) (*Perm, *Response, error)
// List returns a list of repositories.
List(context.Context, ListOptions) ([]*Repository, *Response, error)
// ListV2 returns a list of repositories based on the searchTerm passed.
ListV2(context.Context, RepoListOptions) ([]*Repository, *Response, error)
// ListNamespace returns a list of repos in namespace
ListNamespace(context.Context, string, ListOptions) ([]*Repository, *Response, error)
// ListHooks returns a list or repository hooks.
ListHooks(context.Context, string, ListOptions) ([]*Hook, *Response, error)
// ListStatus returns a list of commit statuses.
ListStatus(context.Context, string, string, ListOptions) ([]*Status, *Response, error)
// CreateHook creates a new repository hook.
CreateHook(context.Context, string, *HookInput) (*Hook, *Response, error)
// CreateStatus creates a new commit status.
CreateStatus(context.Context, string, string, *StatusInput) (*Status, *Response, error)
// UpdateHook updates an existing repository hook.
UpdateHook(context.Context, string, string, *HookInput) (*Hook, *Response, error)
// DeleteHook deletes a repository hook.
DeleteHook(context.Context, string, string) (*Response, error)
}
)
// TODO(bradrydzewski): Add endpoint to get a repository deploy key
// TODO(bradrydzewski): Add endpoint to list repository deploy keys
// TODO(bradrydzewski): Add endpoint to create a repository deploy key
// TODO(bradrydzewski): Add endpoint to delete a repository deploy key