diff --git a/github/github-accessors.go b/github/github-accessors.go index 3d42907b96c..9c435048aec 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -5590,6 +5590,14 @@ func (e *EnterpriseSecurityAnalysisSettings) GetSecretScanningPushProtectionEnab return *e.SecretScanningPushProtectionEnabledForNewRepositories } +// GetCanAdminsBypass returns the CanAdminsBypass field if it's non-nil, zero value otherwise. +func (e *Environment) GetCanAdminsBypass() bool { + if e == nil || e.CanAdminsBypass == nil { + return false + } + return *e.CanAdminsBypass +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (e *Environment) GetCreatedAt() Timestamp { if e == nil || e.CreatedAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 20ba7425d7a..5091cc46c90 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -6541,6 +6541,16 @@ func TestEnterpriseSecurityAnalysisSettings_GetSecretScanningPushProtectionEnabl e.GetSecretScanningPushProtectionEnabledForNewRepositories() } +func TestEnvironment_GetCanAdminsBypass(tt *testing.T) { + var zeroValue bool + e := &Environment{CanAdminsBypass: &zeroValue} + e.GetCanAdminsBypass() + e = &Environment{} + e.GetCanAdminsBypass() + e = nil + e.GetCanAdminsBypass() +} + func TestEnvironment_GetCreatedAt(tt *testing.T) { var zeroValue Timestamp e := &Environment{CreatedAt: &zeroValue} diff --git a/github/repos_environments.go b/github/repos_environments.go index 2e85fdf99c0..7f01be6277f 100644 --- a/github/repos_environments.go +++ b/github/repos_environments.go @@ -28,6 +28,7 @@ type Environment struct { HTMLURL *string `json:"html_url,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` + CanAdminsBypass *bool `json:"can_admins_bypass,omitempty"` ProtectionRules []*ProtectionRule `json:"protection_rules,omitempty"` } diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 0b27da933d7..a688b221fc2 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -145,7 +145,7 @@ func TestRepositoriesService_GetEnvironment(t *testing.T) { mux.HandleFunc("/repos/o/r/environments/e", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id": 1,"name": "staging", "deployment_branch_policy": {"protected_branches": true, "custom_branch_policies": false}}`) + fmt.Fprint(w, `{"id": 1,"name": "staging", "deployment_branch_policy": {"protected_branches": true, "custom_branch_policies": false}, "can_admins_bypass": false}`) }) ctx := context.Background() @@ -154,7 +154,7 @@ func TestRepositoriesService_GetEnvironment(t *testing.T) { t.Errorf("Repositories.GetEnvironment returned error: %v\n%v", err, resp.Body) } - want := &Environment{ID: Int64(1), Name: String("staging"), DeploymentBranchPolicy: &BranchPolicy{ProtectedBranches: Bool(true), CustomBranchPolicies: Bool(false)}} + want := &Environment{ID: Int64(1), Name: String("staging"), DeploymentBranchPolicy: &BranchPolicy{ProtectedBranches: Bool(true), CustomBranchPolicies: Bool(false)}, CanAdminsBypass: Bool(false)} if !cmp.Equal(release, want) { t.Errorf("Repositories.GetEnvironment returned %+v, want %+v", release, want) }