Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit b6e96f9

Browse files
committed
Rename the new structs and functions
1 parent 7c17faf commit b6e96f9

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

job_token_scope.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,29 +185,29 @@ func (j *JobTokenScopeService) RemoveProjectFromJobScopeAllowList(pid interface{
185185
return j.client.Do(req, nil)
186186
}
187187

188-
// JobTokenInboundGroupsAllowItem represents a single job token inbound group allowlist item.
188+
// JobTokenAllowlistItem represents a single job token allowlist item.
189189
//
190190
// GitLab API docs: https://docs.gitlab.com/ee/api/project_job_token_scopes.html
191-
type JobTokenInboundGroupsAllowItem struct {
191+
type JobTokenAllowlistItem struct {
192192
SourceProjectID int `json:"source_project_id"`
193193
TargetGroupID int `json:"target_group_id"`
194194
}
195195

196-
// GetJobTokenInboundGroupsAllowListOptions represents the available
197-
// GetJobTokenInboundGroupsAllowList() options.
196+
// GetJobTokenAllowlistGroupsOptions represents the available
197+
// GetJobTokenAllowlistGroups() options.
198198
//
199199
// GitLab API docs:
200-
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#get-a-projects-cicd-job-token-inbound-allowlist
201-
type GetJobTokenInboundGroupsAllowListOptions struct {
200+
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#get-a-projects-cicd-job-token-allowlist-of-groups
201+
type GetJobTokenAllowlistGroupsOptions struct {
202202
ListOptions
203203
}
204204

205-
// GetProjectJobTokenInboundGroupsAllowList fetches the CI/CD job token inbound
206-
// groups allowlist (job token scope) of a project.
205+
// GetJobTokenAllowListGroups fetches the CI/CD job token allowlist groups
206+
// (job token scopes) of a project.
207207
//
208208
// GitLab API docs:
209209
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#get-a-projects-cicd-job-token-allowlist-of-groups
210-
func (j *JobTokenScopeService) GetProjectJobTokenInboundGroupsAllowList(pid interface{}, opt *GetJobTokenInboundGroupsAllowListOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) {
210+
func (j *JobTokenScopeService) GetJobTokenAllowlistGroups(pid interface{}, opt *GetJobTokenAllowlistGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) {
211211
project, err := parseID(pid)
212212
if err != nil {
213213
return nil, nil, err
@@ -228,12 +228,12 @@ func (j *JobTokenScopeService) GetProjectJobTokenInboundGroupsAllowList(pid inte
228228
return ps, resp, nil
229229
}
230230

231-
// AddProjectToJobScopeGroupsAllowListOptions represents the available
232-
// AddProjectToJobScopeGroupsAllowList() options.
231+
// AddGroupToJobTokenAllowlistOptions represents the available
232+
// AddGroupToJobTokenAllowlist() options.
233233
//
234234
// GitLab API docs:
235235
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#add-a-group-to-a-cicd-job-token-allowlist
236-
type JobTokenInboundGroupsAllowOptions struct {
236+
type AddGroupToJobTokenAllowlistOptions struct {
237237
TargetGroupID *int `url:"target_group_id,omitempty" json:"target_group_id,omitempty"`
238238
}
239239

@@ -242,7 +242,7 @@ type JobTokenInboundGroupsAllowOptions struct {
242242
//
243243
// GitLab API docs:
244244
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#add-a-group-to-a-cicd-job-token-allowlist
245-
func (j *JobTokenScopeService) AddGroupToJobScopeGroupsAllowList(pid interface{}, opt *JobTokenInboundGroupsAllowOptions, options ...RequestOptionFunc) (*JobTokenInboundGroupsAllowItem, *Response, error) {
245+
func (j *JobTokenScopeService) AddGroupToJobTokenAllowlist(pid interface{}, opt *AddGroupToJobTokenAllowlistOptions, options ...RequestOptionFunc) (*JobTokenAllowlistItem, *Response, error) {
246246
project, err := parseID(pid)
247247
if err != nil {
248248
return nil, nil, err
@@ -254,7 +254,7 @@ func (j *JobTokenScopeService) AddGroupToJobScopeGroupsAllowList(pid interface{}
254254
return nil, nil, err
255255
}
256256

257-
jt := new(JobTokenInboundGroupsAllowItem)
257+
jt := new(JobTokenAllowlistItem)
258258
resp, err := j.client.Do(req, jt)
259259
if err != nil {
260260
return nil, resp, err
@@ -263,12 +263,12 @@ func (j *JobTokenScopeService) AddGroupToJobScopeGroupsAllowList(pid interface{}
263263
return jt, resp, nil
264264
}
265265

266-
// RemoveGroupFromJobScopeAllowList removes a group from a project's job
266+
// RemoveGroupFromJopTokenAllowlist removes a group from a project's job
267267
// token inbound groups allow list.
268268
//
269269
// GitLab API docs:
270270
// https://docs.gitlab.com/ee/api/project_job_token_scopes.html#remove-a-group-from-a-cicd-job-token-allowlist
271-
func (j *JobTokenScopeService) RemoveGroupFromJobScopeGroupsAllowList(pid interface{}, targetGroup int, options ...RequestOptionFunc) (*Response, error) {
271+
func (j *JobTokenScopeService) RemoveGroupFromJobTokenAllowlist(pid interface{}, targetGroup int, options ...RequestOptionFunc) (*Response, error) {
272272
project, err := parseID(pid)
273273
if err != nil {
274274
return nil, err

job_token_scope_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ func TestRemoveProjectFromJobScopeAllowList(t *testing.T) {
178178
assert.Equal(t, 204, resp.StatusCode)
179179
}
180180

181-
// This tests that when calling the GetProjectJobTokenInboundGroupsAllowList, we
182-
// get a list of groups back properly. There isn't a "deep" test with every
183-
// attribute specified, because the object returned is a *Group object, which
184-
// is already tested in groups.go.
185-
func TestGetProjectJobTokenInboundGroupsAllowList(t *testing.T) {
181+
// This tests that when calling the GetJobTokenAllowlistGroups, we get a list
182+
// of groups back. There isn't a "deep" test with every attribute specified,
183+
// because the object returned is a *Group object, which is already tested in
184+
// groups.go.
185+
func TestGetJobTokenAllowlistGroups(t *testing.T) {
186186
mux, client := setup(t)
187187

188188
// Handle project ID 1, and print a result of two groups
@@ -194,16 +194,16 @@ func TestGetProjectJobTokenInboundGroupsAllowList(t *testing.T) {
194194
})
195195

196196
want := []*Group{{ID: 1}, {ID: 2}}
197-
groups, _, err := client.JobTokenScope.GetProjectJobTokenInboundGroupsAllowList(
197+
groups, _, err := client.JobTokenScope.GetJobTokenAllowlistGroups(
198198
1,
199-
&GetJobTokenInboundGroupsAllowListOptions{},
199+
&GetJobTokenAllowlistGroupsOptions{},
200200
)
201201

202202
assert.NoError(t, err)
203203
assert.Equal(t, want, groups)
204204
}
205205

206-
func TestAddGroupToJobScopeGroupsAllowList(t *testing.T) {
206+
func TestAddGroupToJobTokenAllowlist(t *testing.T) {
207207
mux, client := setup(t)
208208

209209
mux.HandleFunc("/api/v4/projects/1/job_token_scope/groups_allowlist", func(w http.ResponseWriter, r *http.Request) {
@@ -212,14 +212,14 @@ func TestAddGroupToJobScopeGroupsAllowList(t *testing.T) {
212212
// Read the request to determine which target group is passed in
213213
body, err := io.ReadAll(r.Body)
214214
if err != nil {
215-
t.Fatalf("JobTokenScope.AddGroupToJobScopeGroupsAllowList failed to read body")
215+
t.Fatalf("JobTokenScope.AddGroupToJobTokenAllowlist failed to read body")
216216
}
217217

218218
// Parse to object to ensure it's sent on the request appropriately.
219-
var createTokenRequest JobTokenInboundGroupsAllowOptions
219+
var createTokenRequest AddGroupToJobTokenAllowlistOptions
220220
err = json.Unmarshal(body, &createTokenRequest)
221221
if err != nil {
222-
t.Fatalf("JobTokenScope.AddGroupToJobScopeGroupsAllowList failed to unmarshal body: %v", err)
222+
t.Fatalf("JobTokenScope.AddGroupToJobTokenAllowlist failed to unmarshal body: %v", err)
223223
}
224224

225225
// Ensure we provide the proper response
@@ -232,21 +232,21 @@ func TestAddGroupToJobScopeGroupsAllowList(t *testing.T) {
232232
}`, *createTokenRequest.TargetGroupID)
233233
})
234234

235-
want := &JobTokenInboundGroupsAllowItem{
235+
want := &JobTokenAllowlistItem{
236236
SourceProjectID: 1,
237237
TargetGroupID: 2,
238238
}
239239

240-
addTokenResponse, resp, err := client.JobTokenScope.AddGroupToJobScopeGroupsAllowList(
240+
addTokenResponse, resp, err := client.JobTokenScope.AddGroupToJobTokenAllowlist(
241241
1,
242-
&JobTokenInboundGroupsAllowOptions{TargetGroupID: Ptr(2)},
242+
&AddGroupToJobTokenAllowlistOptions{TargetGroupID: Ptr(2)},
243243
)
244244
assert.NoError(t, err)
245245
assert.Equal(t, want, addTokenResponse)
246246
assert.Equal(t, 201, resp.StatusCode)
247247
}
248248

249-
func TestRemoveGroupFromJobScopeGroupsAllowList(t *testing.T) {
249+
func TestRemoveGroupFromJobTokenAllowlist(t *testing.T) {
250250
mux, client := setup(t)
251251

252252
mux.HandleFunc("/api/v4/projects/1/job_token_scope/groups_allowlist/2", func(w http.ResponseWriter, r *http.Request) {
@@ -255,12 +255,12 @@ func TestRemoveGroupFromJobScopeGroupsAllowList(t *testing.T) {
255255
// Read the request to determine which target group is passed in
256256
body, err := io.ReadAll(r.Body)
257257
if err != nil {
258-
t.Fatalf("JobTokenScope.RemoveGroupFromJobScopeGroupsAllowList failed to read body")
258+
t.Fatalf("JobTokenScope.RemoveGroupFromJobTokenAllowlist failed to read body")
259259
}
260260

261261
// The body should be empty since all attributes are passed in the path
262262
if body != nil && string(body) != "" {
263-
t.Fatalf("JobTokenScope.RemoveGroupFromJobScopeGroupsAllowList failed to unmarshal body: %v", err)
263+
t.Fatalf("JobTokenScope.RemoveGroupFromJobTokenAllowlist failed to unmarshal body: %v", err)
264264
}
265265

266266
// Ensure we provide the proper response
@@ -270,7 +270,7 @@ func TestRemoveGroupFromJobScopeGroupsAllowList(t *testing.T) {
270270
fmt.Fprint(w, "")
271271
})
272272

273-
resp, err := client.JobTokenScope.RemoveGroupFromJobScopeGroupsAllowList(1, 2)
273+
resp, err := client.JobTokenScope.RemoveGroupFromJobTokenAllowlist(1, 2)
274274
assert.NoError(t, err)
275275
assert.Equal(t, 204, resp.StatusCode)
276276
}

0 commit comments

Comments
 (0)