Skip to content

Commit 78c5d00

Browse files
authored
Add CanAdminsBypass to CreateUpdateEnvironment (#2727)
Fixes: #2725.
1 parent 983285f commit 78c5d00

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos_environments.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ func (s *RepositoriesService) GetEnvironment(ctx context.Context, owner, repo, n
148148

149149
// MarshalJSON implements the json.Marshaler interface.
150150
// As the only way to clear a WaitTimer is to set it to 0, a missing WaitTimer object should default to 0, not null.
151+
// As the default value for CanAdminsBypass is true, a nil value here marshals to true.
151152
func (c *CreateUpdateEnvironment) MarshalJSON() ([]byte, error) {
152153
type Alias CreateUpdateEnvironment
153154
if c.WaitTimer == nil {
154155
c.WaitTimer = Int(0)
155156
}
157+
if c.CanAdminsBypass == nil {
158+
c.CanAdminsBypass = Bool(true)
159+
}
156160
return json.Marshal(&struct {
157161
*Alias
158162
}{
@@ -167,6 +171,7 @@ func (c *CreateUpdateEnvironment) MarshalJSON() ([]byte, error) {
167171
type CreateUpdateEnvironment struct {
168172
WaitTimer *int `json:"wait_timer"`
169173
Reviewers []*EnvReviewers `json:"reviewers"`
174+
CanAdminsBypass *bool `json:"can_admins_bypass"`
170175
DeploymentBranchPolicy *BranchPolicy `json:"deployment_branch_policy"`
171176
}
172177

github/repos_environments_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestCreateUpdateEnvironment_MarshalJSON(t *testing.T) {
9393
t.Errorf("MarshalJSON: %v", err)
9494
}
9595

96-
want := `{"wait_timer":0,"reviewers":null,"deployment_branch_policy":null}`
96+
want := `{"wait_timer":0,"reviewers":null,"can_admins_bypass":true,"deployment_branch_policy":null}`
9797
if string(got) != want {
9898
t.Errorf("MarshalJSON = %s, want %v", got, want)
9999
}
@@ -187,7 +187,7 @@ func TestRepositoriesService_CreateEnvironment(t *testing.T) {
187187
json.NewDecoder(r.Body).Decode(v)
188188

189189
testMethod(t, r, "PUT")
190-
want := &CreateUpdateEnvironment{WaitTimer: Int(30)}
190+
want := &CreateUpdateEnvironment{WaitTimer: Int(30), CanAdminsBypass: Bool(true)}
191191
if !cmp.Equal(v, want) {
192192
t.Errorf("Request body = %+v, want %+v", v, want)
193193
}

0 commit comments

Comments
 (0)