Skip to content

Commit 0b20009

Browse files
author
Sander van Harmelen
authored
1 parent 055ffe6 commit 0b20009

27 files changed

+485
-510
lines changed

branches.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ func (b Branch) String() string {
4747
//
4848
// GitLab API docs:
4949
// https://docs.gitlab.com/ce/api/branches.html#list-repository-branches
50-
func (s *BranchesService) ListBranches(pid interface{}) ([]*Branch, *Response, error) {
50+
func (s *BranchesService) ListBranches(pid interface{}, sudoFunc ...SudoFunc) ([]*Branch, *Response, error) {
5151
project, err := parseID(pid)
5252
if err != nil {
5353
return nil, nil, err
5454
}
5555
u := fmt.Sprintf("projects/%s/repository/branches", url.QueryEscape(project))
5656

57-
req, err := s.client.NewRequest("GET", u, nil)
57+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
5858
if err != nil {
5959
return nil, nil, err
6060
}
@@ -72,14 +72,14 @@ func (s *BranchesService) ListBranches(pid interface{}) ([]*Branch, *Response, e
7272
//
7373
// GitLab API docs:
7474
// https://docs.gitlab.com/ce/api/branches.html#get-single-repository-branch
75-
func (s *BranchesService) GetBranch(pid interface{}, branch string) (*Branch, *Response, error) {
75+
func (s *BranchesService) GetBranch(pid interface{}, branch string, sudoFunc ...SudoFunc) (*Branch, *Response, error) {
7676
project, err := parseID(pid)
7777
if err != nil {
7878
return nil, nil, err
7979
}
8080
u := fmt.Sprintf("projects/%s/repository/branches/%s", url.QueryEscape(project), branch)
8181

82-
req, err := s.client.NewRequest("GET", u, nil)
82+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
8383
if err != nil {
8484
return nil, nil, err
8585
}
@@ -99,14 +99,14 @@ func (s *BranchesService) GetBranch(pid interface{}, branch string) (*Branch, *R
9999
//
100100
// GitLab API docs:
101101
// https://docs.gitlab.com/ce/api/branches.html#protect-repository-branch
102-
func (s *BranchesService) ProtectBranch(pid interface{}, branch string) (*Branch, *Response, error) {
102+
func (s *BranchesService) ProtectBranch(pid interface{}, branch string, sudoFunc ...SudoFunc) (*Branch, *Response, error) {
103103
project, err := parseID(pid)
104104
if err != nil {
105105
return nil, nil, err
106106
}
107107
u := fmt.Sprintf("projects/%s/repository/branches/%s/protect", url.QueryEscape(project), branch)
108108

109-
req, err := s.client.NewRequest("PUT", u, nil)
109+
req, err := s.client.NewRequest("PUT", u, nil, sudoFunc)
110110
if err != nil {
111111
return nil, nil, err
112112
}
@@ -126,14 +126,14 @@ func (s *BranchesService) ProtectBranch(pid interface{}, branch string) (*Branch
126126
//
127127
// GitLab API docs:
128128
// https://docs.gitlab.com/ce/api/branches.html#unprotect-repository-branch
129-
func (s *BranchesService) UnprotectBranch(pid interface{}, branch string) (*Branch, *Response, error) {
129+
func (s *BranchesService) UnprotectBranch(pid interface{}, branch string, sudoFunc ...SudoFunc) (*Branch, *Response, error) {
130130
project, err := parseID(pid)
131131
if err != nil {
132132
return nil, nil, err
133133
}
134134
u := fmt.Sprintf("projects/%s/repository/branches/%s/unprotect", url.QueryEscape(project), branch)
135135

136-
req, err := s.client.NewRequest("PUT", u, nil)
136+
req, err := s.client.NewRequest("PUT", u, nil, sudoFunc)
137137
if err != nil {
138138
return nil, nil, err
139139
}
@@ -160,14 +160,14 @@ type CreateBranchOptions struct {
160160
//
161161
// GitLab API docs:
162162
// https://docs.gitlab.com/ce/api/branches.html#create-repository-branch
163-
func (s *BranchesService) CreateBranch(pid interface{}, opt *CreateBranchOptions) (*Branch, *Response, error) {
163+
func (s *BranchesService) CreateBranch(pid interface{}, opt *CreateBranchOptions, sudoFunc ...SudoFunc) (*Branch, *Response, error) {
164164
project, err := parseID(pid)
165165
if err != nil {
166166
return nil, nil, err
167167
}
168168
u := fmt.Sprintf("projects/%s/repository/branches", url.QueryEscape(project))
169169

170-
req, err := s.client.NewRequest("POST", u, opt)
170+
req, err := s.client.NewRequest("POST", u, opt, sudoFunc)
171171
if err != nil {
172172
return nil, nil, err
173173
}
@@ -185,14 +185,14 @@ func (s *BranchesService) CreateBranch(pid interface{}, opt *CreateBranchOptions
185185
//
186186
// GitLab API docs:
187187
// https://docs.gitlab.com/ce/api/branches.html#delete-repository-branch
188-
func (s *BranchesService) DeleteBranch(pid interface{}, branch string) (*Response, error) {
188+
func (s *BranchesService) DeleteBranch(pid interface{}, branch string, sudoFunc ...SudoFunc) (*Response, error) {
189189
project, err := parseID(pid)
190190
if err != nil {
191191
return nil, err
192192
}
193193
u := fmt.Sprintf("projects/%s/repository/branches/%s", url.QueryEscape(project), branch)
194194

195-
req, err := s.client.NewRequest("DELETE", u, nil)
195+
req, err := s.client.NewRequest("DELETE", u, nil, sudoFunc)
196196
if err != nil {
197197
return nil, err
198198
}

build_variables.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ func (v BuildVariable) String() string {
2929
//
3030
// Gitlab API Docs:
3131
// https://docs.gitlab.com/ce/api/build_variables.html#list-project-variables
32-
func (s *BuildVariablesService) ListBuildVariables(pid interface{}) ([]*BuildVariable, *Response, error) {
32+
func (s *BuildVariablesService) ListBuildVariables(pid interface{}, sudoFunc ...SudoFunc) ([]*BuildVariable, *Response, error) {
3333
project, err := parseID(pid)
3434
if err != nil {
3535
return nil, nil, err
3636
}
3737
u := fmt.Sprintf("projects/%s/variables", url.QueryEscape(project))
3838

39-
req, err := s.client.NewRequest("GET", u, nil)
39+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
4040
if err != nil {
4141
return nil, nil, err
4242
}
@@ -54,14 +54,14 @@ func (s *BuildVariablesService) ListBuildVariables(pid interface{}) ([]*BuildVar
5454
//
5555
// Gitlab API Docs:
5656
// https://docs.gitlab.com/ce/api/build_variables.html#show-variable-details
57-
func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string) (*BuildVariable, *Response, error) {
57+
func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string, sudoFunc ...SudoFunc) (*BuildVariable, *Response, error) {
5858
project, err := parseID(pid)
5959
if err != nil {
6060
return nil, nil, err
6161
}
6262
u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key)
6363

64-
req, err := s.client.NewRequest("GET", u, nil)
64+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
6565
if err != nil {
6666
return nil, nil, err
6767
}
@@ -79,14 +79,14 @@ func (s *BuildVariablesService) GetBuildVariable(pid interface{}, key string) (*
7979
//
8080
// Gitlab API Docs:
8181
// https://docs.gitlab.com/ce/api/build_variables.html#create-variable
82-
func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value string) (*BuildVariable, *Response, error) {
82+
func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value string, sudoFunc ...SudoFunc) (*BuildVariable, *Response, error) {
8383
project, err := parseID(pid)
8484
if err != nil {
8585
return nil, nil, err
8686
}
8787
u := fmt.Sprintf("projects/%s/variables", url.QueryEscape(project))
8888

89-
req, err := s.client.NewRequest("POST", u, BuildVariable{key, value})
89+
req, err := s.client.NewRequest("POST", u, BuildVariable{key, value}, sudoFunc)
9090
if err != nil {
9191
return nil, nil, err
9292
}
@@ -105,14 +105,14 @@ func (s *BuildVariablesService) CreateBuildVariable(pid interface{}, key, value
105105
//
106106
// Gitlab API Docs:
107107
// https://docs.gitlab.com/ce/api/build_variables.html#update-variable
108-
func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value string) (*BuildVariable, *Response, error) {
108+
func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value string, sudoFunc ...SudoFunc) (*BuildVariable, *Response, error) {
109109
project, err := parseID(pid)
110110
if err != nil {
111111
return nil, nil, err
112112
}
113113
u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key)
114114

115-
req, err := s.client.NewRequest("PUT", u, BuildVariable{key, value})
115+
req, err := s.client.NewRequest("PUT", u, BuildVariable{key, value}, sudoFunc)
116116
if err != nil {
117117
return nil, nil, err
118118
}
@@ -130,14 +130,14 @@ func (s *BuildVariablesService) UpdateBuildVariable(pid interface{}, key, value
130130
//
131131
// Gitlab API Docs:
132132
// https://docs.gitlab.com/ce/api/build_variables.html#remove-variable
133-
func (s *BuildVariablesService) RemoveBuildVariable(pid interface{}, key string) (*Response, error) {
133+
func (s *BuildVariablesService) RemoveBuildVariable(pid interface{}, key string, sudoFunc ...SudoFunc) (*Response, error) {
134134
project, err := parseID(pid)
135135
if err != nil {
136136
return nil, err
137137
}
138138
u := fmt.Sprintf("projects/%s/variables/%s", url.QueryEscape(project), key)
139139

140-
req, err := s.client.NewRequest("DELETE", u, nil)
140+
req, err := s.client.NewRequest("DELETE", u, nil, sudoFunc)
141141
if err != nil {
142142
return nil, err
143143
}

builds.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ type Build struct {
7373
//
7474
// GitLab API docs:
7575
// https://docs.gitlab.com/ce/api/builds.html#list-project-builds
76-
func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptions) ([]Build, *Response, error) {
76+
func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptions, sudoFunc ...SudoFunc) ([]Build, *Response, error) {
7777
project, err := parseID(pid)
7878
if err != nil {
7979
return nil, nil, err
8080
}
8181
u := fmt.Sprintf("projects/%s/builds", url.QueryEscape(project))
8282

83-
req, err := s.client.NewRequest("GET", u, opts)
83+
req, err := s.client.NewRequest("GET", u, opts, sudoFunc)
8484
if err != nil {
8585
return nil, nil, err
8686
}
@@ -99,14 +99,14 @@ func (s *BuildsService) ListProjectBuilds(pid interface{}, opts *ListBuildsOptio
9999
//
100100
// GitLab API docs:
101101
// https://docs.gitlab.com/ce/api/builds.html#list-commit-builds
102-
func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *ListBuildsOptions) ([]Build, *Response, error) {
102+
func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *ListBuildsOptions, sudoFunc ...SudoFunc) ([]Build, *Response, error) {
103103
project, err := parseID(pid)
104104
if err != nil {
105105
return nil, nil, err
106106
}
107107
u := fmt.Sprintf("projects/%s/repository/commits/%s/builds", project, sha)
108108

109-
req, err := s.client.NewRequest("GET", u, opts)
109+
req, err := s.client.NewRequest("GET", u, opts, sudoFunc)
110110
if err != nil {
111111
return nil, nil, err
112112
}
@@ -124,14 +124,14 @@ func (s *BuildsService) ListCommitBuilds(pid interface{}, sha string, opts *List
124124
//
125125
// GitLab API docs:
126126
// https://docs.gitlab.com/ce/api/builds.html#get-a-single-build
127-
func (s *BuildsService) GetBuild(pid interface{}, buildID int) (*Build, *Response, error) {
127+
func (s *BuildsService) GetBuild(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
128128
project, err := parseID(pid)
129129
if err != nil {
130130
return nil, nil, err
131131
}
132132
u := fmt.Sprintf("projects/%s/builds/%d", project, buildID)
133133

134-
req, err := s.client.NewRequest("GET", u, nil)
134+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
135135
if err != nil {
136136
return nil, nil, err
137137
}
@@ -149,14 +149,14 @@ func (s *BuildsService) GetBuild(pid interface{}, buildID int) (*Build, *Respons
149149
//
150150
// GitLab API docs:
151151
// https://docs.gitlab.com/ce/api/builds.html#get-build-artifacts
152-
func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int) (io.Reader, *Response, error) {
152+
func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int, sudoFunc ...SudoFunc) (io.Reader, *Response, error) {
153153
project, err := parseID(pid)
154154
if err != nil {
155155
return nil, nil, err
156156
}
157157
u := fmt.Sprintf("projects/%s/builds/%d/artifacts", project, buildID)
158158

159-
req, err := s.client.NewRequest("GET", u, nil)
159+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
160160
if err != nil {
161161
return nil, nil, err
162162
}
@@ -175,14 +175,14 @@ func (s *BuildsService) GetBuildArtifacts(pid interface{}, buildID int) (io.Read
175175
//
176176
// GitLab API docs:
177177
// https://docs.gitlab.com/ce/api/builds.html#download-the-artifacts-file
178-
func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, job string) (io.Reader, *Response, error) {
178+
func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, job string, sudoFunc ...SudoFunc) (io.Reader, *Response, error) {
179179
project, err := parseID(pid)
180180
if err != nil {
181181
return nil, nil, err
182182
}
183183
u := fmt.Sprintf("projects/%s/builds/artifacts/%s/download?job=%s", project, refName, job)
184184

185-
req, err := s.client.NewRequest("GET", u, nil)
185+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
186186
if err != nil {
187187
return nil, nil, err
188188
}
@@ -200,14 +200,14 @@ func (s *BuildsService) DownloadArtifactsFile(pid interface{}, refName string, j
200200
//
201201
// GitLab API docs:
202202
// https://docs.gitlab.com/ce/api/builds.html#get-a-trace-file
203-
func (s *BuildsService) GetTraceFile(pid interface{}, buildID int) (io.Reader, *Response, error) {
203+
func (s *BuildsService) GetTraceFile(pid interface{}, buildID int, sudoFunc ...SudoFunc) (io.Reader, *Response, error) {
204204
project, err := parseID(pid)
205205
if err != nil {
206206
return nil, nil, err
207207
}
208208
u := fmt.Sprintf("projects/%s/builds/%d/trace", project, buildID)
209209

210-
req, err := s.client.NewRequest("GET", u, nil)
210+
req, err := s.client.NewRequest("GET", u, nil, sudoFunc)
211211
if err != nil {
212212
return nil, nil, err
213213
}
@@ -225,14 +225,14 @@ func (s *BuildsService) GetTraceFile(pid interface{}, buildID int) (io.Reader, *
225225
//
226226
// GitLab API docs:
227227
// https://docs.gitlab.com/ce/api/builds.html#cancel-a-build
228-
func (s *BuildsService) CancelBuild(pid interface{}, buildID int) (*Build, *Response, error) {
228+
func (s *BuildsService) CancelBuild(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
229229
project, err := parseID(pid)
230230
if err != nil {
231231
return nil, nil, err
232232
}
233233
u := fmt.Sprintf("projects/%s/builds/%d/cancel", project, buildID)
234234

235-
req, err := s.client.NewRequest("POST", u, nil)
235+
req, err := s.client.NewRequest("POST", u, nil, sudoFunc)
236236
if err != nil {
237237
return nil, nil, err
238238
}
@@ -250,14 +250,14 @@ func (s *BuildsService) CancelBuild(pid interface{}, buildID int) (*Build, *Resp
250250
//
251251
// GitLab API docs:
252252
// https://docs.gitlab.com/ce/api/builds.html#retry-a-build
253-
func (s *BuildsService) RetryBuild(pid interface{}, buildID int) (*Build, *Response, error) {
253+
func (s *BuildsService) RetryBuild(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
254254
project, err := parseID(pid)
255255
if err != nil {
256256
return nil, nil, err
257257
}
258258
u := fmt.Sprintf("projects/%s/builds/%d/retry", project, buildID)
259259

260-
req, err := s.client.NewRequest("POST", u, nil)
260+
req, err := s.client.NewRequest("POST", u, nil, sudoFunc)
261261
if err != nil {
262262
return nil, nil, err
263263
}
@@ -276,14 +276,14 @@ func (s *BuildsService) RetryBuild(pid interface{}, buildID int) (*Build, *Respo
276276
//
277277
// GitLab API docs:
278278
// https://docs.gitlab.com/ce/api/builds.html#erase-a-build
279-
func (s *BuildsService) EraseBuild(pid interface{}, buildID int) (*Build, *Response, error) {
279+
func (s *BuildsService) EraseBuild(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
280280
project, err := parseID(pid)
281281
if err != nil {
282282
return nil, nil, err
283283
}
284284
u := fmt.Sprintf("projects/%s/builds/%d/erase", project, buildID)
285285

286-
req, err := s.client.NewRequest("POST", u, nil)
286+
req, err := s.client.NewRequest("POST", u, nil, sudoFunc)
287287
if err != nil {
288288
return nil, nil, err
289289
}
@@ -302,14 +302,14 @@ func (s *BuildsService) EraseBuild(pid interface{}, buildID int) (*Build, *Respo
302302
//
303303
// GitLab API docs:
304304
// https://docs.gitlab.com/ce/api/builds.html#keep-artifacts
305-
func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int) (*Build, *Response, error) {
305+
func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
306306
project, err := parseID(pid)
307307
if err != nil {
308308
return nil, nil, err
309309
}
310310
u := fmt.Sprintf("projects/%s/builds/%d/artifacts/keep", project, buildID)
311311

312-
req, err := s.client.NewRequest("POST", u, nil)
312+
req, err := s.client.NewRequest("POST", u, nil, sudoFunc)
313313
if err != nil {
314314
return nil, nil, err
315315
}
@@ -327,14 +327,14 @@ func (s *BuildsService) KeepArtifacts(pid interface{}, buildID int) (*Build, *Re
327327
//
328328
// GitLab API docs:
329329
// https://docs.gitlab.com/ce/api/builds.html#play-a-build
330-
func (s *BuildsService) PlayBuild(pid interface{}, buildID int) (*Build, *Response, error) {
330+
func (s *BuildsService) PlayBuild(pid interface{}, buildID int, sudoFunc ...SudoFunc) (*Build, *Response, error) {
331331
project, err := parseID(pid)
332332
if err != nil {
333333
return nil, nil, err
334334
}
335335
u := fmt.Sprintf("projects/%s/builds/%d/play", project, buildID)
336336

337-
req, err := s.client.NewRequest("POST", u, nil)
337+
req, err := s.client.NewRequest("POST", u, nil, sudoFunc)
338338
if err != nil {
339339
return nil, nil, err
340340
}

0 commit comments

Comments
 (0)