diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index 3c5dc89c757..1e8a5ef640a 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -21,7 +21,7 @@ func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":3,"runner_groups":[{"id":1,"name":"Default","visibility":"all","default":true,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners","inherited":false,"allows_public_repositories":true},{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":true,"allows_public_repositories":true},{"id":3,"name":"expensive-hardware","visibility":"private","default":false,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners","inherited":false,"allows_public_repositories":true}]}`) + fmt.Fprint(w, `{"total_count":3,"runner_groups":[{"id":1,"name":"Default","visibility":"all","default":true,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":true,"selected_workflows":["a","b"]},{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]},{"id":3,"name":"expensive-hardware","visibility":"private","default":false,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}]}`) }) opts := &ListOrgRunnerGroupOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} @@ -34,9 +34,9 @@ func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) { want := &RunnerGroups{ TotalCount: 3, RunnerGroups: []*RunnerGroup{ - {ID: Int64(1), Name: String("Default"), Visibility: String("all"), Default: Bool(true), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, - {ID: Int64(2), Name: String("octo-runner-group"), Visibility: String("selected"), Default: Bool(false), SelectedRepositoriesURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, - {ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, + {ID: Int64(1), Name: String("Default"), Visibility: String("all"), Default: Bool(true), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(true), SelectedWorkflows: []string{"a","b"}}, + {ID: Int64(2), Name: String("octo-runner-group"), Visibility: String("selected"), Default: Bool(false), SelectedRepositoriesURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: []string{}}, + {ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -65,7 +65,7 @@ func TestActionsService_ListOrganizationRunnerGroupsVisibleToRepo(t *testing.T) mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2", "visible_to_repository": "github"}) - fmt.Fprint(w, `{"total_count":3,"runner_groups":[{"id":1,"name":"Default","visibility":"all","default":true,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners","inherited":false,"allows_public_repositories":true},{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":true,"allows_public_repositories":true},{"id":3,"name":"expensive-hardware","visibility":"private","default":false,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners","inherited":false,"allows_public_repositories":true}]}`) + fmt.Fprint(w, `{"total_count":3,"runner_groups":[{"id":1,"name":"Default","visibility":"all","default":true,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]},{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":true,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]},{"id":3,"name":"expensive-hardware","visibility":"private","default":false,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}]}`) }) opts := &ListOrgRunnerGroupOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}, VisibleToRepository: "github"} @@ -78,9 +78,9 @@ func TestActionsService_ListOrganizationRunnerGroupsVisibleToRepo(t *testing.T) want := &RunnerGroups{ TotalCount: 3, RunnerGroups: []*RunnerGroup{ - {ID: Int64(1), Name: String("Default"), Visibility: String("all"), Default: Bool(true), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, - {ID: Int64(2), Name: String("octo-runner-group"), Visibility: String("selected"), Default: Bool(false), SelectedRepositoriesURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, - {ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: nil}, + {ID: Int64(1), Name: String("Default"), Visibility: String("all"), Default: Bool(true), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: []string{}}, + {ID: Int64(2), Name: String("octo-runner-group"), Visibility: String("selected"), Default: Bool(false), SelectedRepositoriesURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Bool(true), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: []string{}}, + {ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true), RestrictedToWorkflows: Bool(false), SelectedWorkflows: []string{}}, }, } if !cmp.Equal(groups, want) { @@ -108,7 +108,7 @@ func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`) + fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`) }) ctx := context.Background() @@ -180,7 +180,7 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`) + fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`) }) ctx := context.Background() @@ -234,7 +234,7 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) { mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`) + fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true,"restricted_to_workflows":false,"selected_workflows":[]}`) }) ctx := context.Background() diff --git a/github/github-accessors.go b/github/github-accessors.go index 5a9700c2cc4..2976c2eb44e 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -3606,22 +3606,6 @@ func (c *CreateProtectedChanges) GetFrom() bool { return *c.From } -// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, false otherwise. -func (c *CreateRunnerGroupRequest) GetRestrictedToWorkflows() bool { - if c == nil || c.RestrictedToWorkflows == nil { - return false - } - return *c.RestrictedToWorkflows -} - -// GetSelectedWorkflows returns the SelectedWorkflows field if it's non-nil, empty array otherwise. -func (c *CreateRunnerGroupRequest) GetSelectedWorkflows() []string { - if c == nil || c.SelectedWorkflows == nil { - return nil - } - return c.SelectedWorkflows -} - // GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise. func (c *CreateRunnerGroupRequest) GetAllowsPublicRepositories() bool { if c == nil || c.AllowsPublicRepositories == nil { @@ -3638,6 +3622,14 @@ func (c *CreateRunnerGroupRequest) GetName() string { return *c.Name } +// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, zero value otherwise. +func (c *CreateRunnerGroupRequest) GetRestrictedToWorkflows() bool { + if c == nil || c.RestrictedToWorkflows == nil { + return false + } + return *c.RestrictedToWorkflows +} + // GetVisibility returns the Visibility field if it's non-nil, zero value otherwise. func (c *CreateRunnerGroupRequest) GetVisibility() string { if c == nil || c.Visibility == nil { @@ -16670,23 +16662,6 @@ func (r *RunnerGroup) GetAllowsPublicRepositories() bool { return *r.AllowsPublicRepositories } -// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, false otherwise. -func (r *RunnerGroup) GetRestrictedToWorkflows() bool { - if r == nil || r.RestrictedToWorkflows == nil { - return false - } - return *r.RestrictedToWorkflows -} - -// GetSelectedWorkflows returns the SelectedWorkflows field if it's non-nil, empty array otherwise. -func (r *RunnerGroup) GetSelectedWorkflows() []string { - if r == nil || r.SelectedWorkflows == nil { - return nil - } - return r.SelectedWorkflows -} - - // GetDefault returns the Default field if it's non-nil, zero value otherwise. func (r *RunnerGroup) GetDefault() bool { if r == nil || r.Default == nil { @@ -16719,6 +16694,14 @@ func (r *RunnerGroup) GetName() string { return *r.Name } +// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, zero value otherwise. +func (r *RunnerGroup) GetRestrictedToWorkflows() bool { + if r == nil || r.RestrictedToWorkflows == nil { + return false + } + return *r.RestrictedToWorkflows +} + // GetRunnersURL returns the RunnersURL field if it's non-nil, zero value otherwise. func (r *RunnerGroup) GetRunnersURL() string { if r == nil || r.RunnersURL == nil { @@ -19199,22 +19182,6 @@ func (u *UpdateRunnerGroupRequest) GetAllowsPublicRepositories() bool { return *u.AllowsPublicRepositories } -// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, false otherwise. -func (u *UpdateRunnerGroupRequest) GetRestrictedToWorkflows() bool { - if u == nil || u.RestrictedToWorkflows == nil { - return false - } - return *u.RestrictedToWorkflows -} - -// GetSelectedWorkflows returns the SelectedWorkflows field if it's non-nil, empty array otherwise. -func (u *UpdateRunnerGroupRequest) GetSelectedWorkflows() []string { - if u == nil || u.SelectedWorkflows == nil { - return nil - } - return u.SelectedWorkflows -} - // GetName returns the Name field if it's non-nil, zero value otherwise. func (u *UpdateRunnerGroupRequest) GetName() string { if u == nil || u.Name == nil { @@ -19223,6 +19190,14 @@ func (u *UpdateRunnerGroupRequest) GetName() string { return *u.Name } +// GetRestrictedToWorkflows returns the RestrictedToWorkflows field if it's non-nil, zero value otherwise. +func (u *UpdateRunnerGroupRequest) GetRestrictedToWorkflows() bool { + if u == nil || u.RestrictedToWorkflows == nil { + return false + } + return *u.RestrictedToWorkflows +} + // GetVisibility returns the Visibility field if it's non-nil, zero value otherwise. func (u *UpdateRunnerGroupRequest) GetVisibility() string { if u == nil || u.Visibility == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 7213e00d213..658f16e1fcc 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4233,26 +4233,6 @@ func TestCreateRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) { c.GetAllowsPublicRepositories() } -func TestCreateRunnerGroupRequest_GetRestrictedToWorkflows(tt *testing.T) { - var zeroValue bool - c := &CreateRunnerGroupRequest{RestrictedToWorkflows: &zeroValue} - c.GetRestrictedToWorkflows() - c = &CreateRunnerGroupRequest{} - c.GetRestrictedToWorkflows() - c = nil - c.GetRestrictedToWorkflows() -} - -func TestCreateRunnerGroupRequest_GetSelectedWorkflows(tt *testing.T) { - var zeroValue []string - c := &CreateRunnerGroupRequest{SelectedWorkflows: zeroValue} - c.GetSelectedWorkflows() - c = &CreateRunnerGroupRequest{} - c.GetSelectedWorkflows() - c = nil - c.GetSelectedWorkflows() -} - func TestCreateRunnerGroupRequest_GetName(tt *testing.T) { var zeroValue string c := &CreateRunnerGroupRequest{Name: &zeroValue} @@ -4263,6 +4243,16 @@ func TestCreateRunnerGroupRequest_GetName(tt *testing.T) { c.GetName() } +func TestCreateRunnerGroupRequest_GetRestrictedToWorkflows(tt *testing.T) { + var zeroValue bool + c := &CreateRunnerGroupRequest{RestrictedToWorkflows: &zeroValue} + c.GetRestrictedToWorkflows() + c = &CreateRunnerGroupRequest{} + c.GetRestrictedToWorkflows() + c = nil + c.GetRestrictedToWorkflows() +} + func TestCreateRunnerGroupRequest_GetVisibility(tt *testing.T) { var zeroValue string c := &CreateRunnerGroupRequest{Visibility: &zeroValue} @@ -19407,26 +19397,6 @@ func TestRunnerGroup_GetAllowsPublicRepositories(tt *testing.T) { r.GetAllowsPublicRepositories() } -func TestRunnerGroup_GetRestrictedToWorkflows(tt *testing.T) { - var zeroValue bool - r := &RunnerGroup{RestrictedToWorkflows: &zeroValue} - r.GetRestrictedToWorkflows() - r = &RunnerGroup{} - r.GetRestrictedToWorkflows() - r = nil - r.GetRestrictedToWorkflows() -} - -func TestRunnerGroup_GetSelectedWorkflows(tt *testing.T) { - var zeroValue []string - r := &RunnerGroup{SelectedWorkflows: zeroValue} - r.GetSelectedWorkflows() - r = &RunnerGroup{} - r.GetSelectedWorkflows() - r = nil - r.GetSelectedWorkflows() -} - func TestRunnerGroup_GetDefault(tt *testing.T) { var zeroValue bool r := &RunnerGroup{Default: &zeroValue} @@ -19467,6 +19437,16 @@ func TestRunnerGroup_GetName(tt *testing.T) { r.GetName() } +func TestRunnerGroup_GetRestrictedToWorkflows(tt *testing.T) { + var zeroValue bool + r := &RunnerGroup{RestrictedToWorkflows: &zeroValue} + r.GetRestrictedToWorkflows() + r = &RunnerGroup{} + r.GetRestrictedToWorkflows() + r = nil + r.GetRestrictedToWorkflows() +} + func TestRunnerGroup_GetRunnersURL(tt *testing.T) { var zeroValue string r := &RunnerGroup{RunnersURL: &zeroValue} @@ -22372,26 +22352,6 @@ func TestUpdateRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) { u.GetAllowsPublicRepositories() } -func TestUpdateRunnerGroupRequest_GetRestrictedToWorkflows(tt *testing.T) { - var zeroValue bool - u := &UpdateRunnerGroupRequest{RestrictedToWorkflows: &zeroValue} - u.GetRestrictedToWorkflows() - u = &UpdateRunnerGroupRequest{} - u.GetRestrictedToWorkflows() - u = nil - u.GetRestrictedToWorkflows() -} - -func TestUpdateRunnerGroupRequest_GetSelectedWorkflows(tt *testing.T) { - var zeroValue []string - u := &UpdateRunnerGroupRequest{SelectedWorkflows: zeroValue} - u.GetSelectedWorkflows() - u = &UpdateRunnerGroupRequest{} - u.GetSelectedWorkflows() - u = nil - u.GetSelectedWorkflows() -} - func TestUpdateRunnerGroupRequest_GetName(tt *testing.T) { var zeroValue string u := &UpdateRunnerGroupRequest{Name: &zeroValue} @@ -22402,6 +22362,16 @@ func TestUpdateRunnerGroupRequest_GetName(tt *testing.T) { u.GetName() } +func TestUpdateRunnerGroupRequest_GetRestrictedToWorkflows(tt *testing.T) { + var zeroValue bool + u := &UpdateRunnerGroupRequest{RestrictedToWorkflows: &zeroValue} + u.GetRestrictedToWorkflows() + u = &UpdateRunnerGroupRequest{} + u.GetRestrictedToWorkflows() + u = nil + u.GetRestrictedToWorkflows() +} + func TestUpdateRunnerGroupRequest_GetVisibility(tt *testing.T) { var zeroValue string u := &UpdateRunnerGroupRequest{Visibility: &zeroValue}