From f5fd9584587a6549b08de7cfc079409b689265e7 Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Thu, 27 Apr 2023 14:15:17 -0400 Subject: [PATCH 1/5] Support deployment protection rule event types This commit adds the deployment_protection_rule event type to the list of parseable event types --- github/event.go | 2 + github/event_types.go | 18 ++ github/event_types_test.go | 339 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 72 +++++++ github/github-accessors_test.go | 72 +++++++ github/messages.go | 1 + 6 files changed, 504 insertions(+) diff --git a/github/event.go b/github/event.go index 1aabf13bade..7ad1cfc89da 100644 --- a/github/event.go +++ b/github/event.go @@ -49,6 +49,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &DeployKeyEvent{} case "DeploymentEvent": payload = &DeploymentEvent{} + case "DeploymentProtectionRule": + payload = &DeploymentProtectionRuleEvent{} case "DeploymentStatusEvent": payload = &DeploymentStatusEvent{} case "DiscussionEvent": diff --git a/github/event_types.go b/github/event_types.go index 685e46f0287..c8eb23e4da2 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -173,6 +173,24 @@ type DeploymentEvent struct { Installation *Installation `json:"installation,omitempty"` } +// DeploymentProtectionRuleEvent represents a deployment protection rule +// The Webhook even name is "deployment_protection_rule". +// +// GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_protection_rule +type DeploymentProtectionRuleEvent struct { + Action *string `json:"action,omitempty"` + Environment *string `json:"environment,omitempty"` + + // The URL Github provides for a third-party to use in order to pass/fail a deployment gate + DeploymentCallbackURL *string `json:"deployment_callback_url,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Organization *Organization `json:"organization,omitempty"` + PullRequest *PullRequest `json:"pull_request,omitempty"` + Sender *User `json:"sender,omitempty"` + Installation *Installation `json:"installation,omitempty"` +} + // DeploymentStatusEvent represents a deployment status. // The Webhook event name is "deployment_status". // diff --git a/github/event_types_test.go b/github/event_types_test.go index cdbaee5542b..5c1fbf2eda2 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -5483,6 +5483,345 @@ func TestDeploymentEvent_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } +func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { + testJSONMarshal(t, &DeploymentProtectionRuleEvent{}, "{}") + + l := make(map[string]interface{}) + l["key"] = "value" + + jsonMsg, _ := json.Marshal(&l) + + u := &DeploymentProtectionRuleEvent{ + Action: String("a"), + Environment: String("e"), + DeploymentCallbackURL: String("b"), + Deployment: &Deployment{ + URL: String("url"), + ID: Int64(1), + SHA: String("sha"), + Ref: String("ref"), + Task: String("t"), + Payload: jsonMsg, + Environment: String("e"), + Description: String("d"), + Creator: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + StatusesURL: String("surl"), + RepositoryURL: String("rurl"), + NodeID: String("nid"), + }, + Repo: &Repository{ + ID: Int64(1), + URL: String("s"), + Name: String("n"), + }, + Organization: &Organization{ + BillingEmail: String("be"), + Blog: String("b"), + Company: String("c"), + Email: String("e"), + TwitterUsername: String("tu"), + Location: String("loc"), + Name: String("n"), + Description: String("d"), + IsVerified: Bool(true), + HasOrganizationProjects: Bool(true), + HasRepositoryProjects: Bool(true), + DefaultRepoPermission: String("drp"), + MembersCanCreateRepos: Bool(true), + MembersCanCreateInternalRepos: Bool(true), + MembersCanCreatePrivateRepos: Bool(true), + MembersCanCreatePublicRepos: Bool(false), + MembersAllowedRepositoryCreationType: String("marct"), + MembersCanCreatePages: Bool(true), + MembersCanCreatePublicPages: Bool(false), + MembersCanCreatePrivatePages: Bool(true), + }, + PullRequest: &PullRequest{ID: Int64(1)}, + Sender: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + Installation: &Installation{ + ID: Int64(1), + NodeID: String("nid"), + AppID: Int64(1), + AppSlug: String("as"), + TargetID: Int64(1), + Account: &User{ + Login: String("l"), + ID: Int64(1), + URL: String("u"), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + Bio: String("b"), + TwitterUsername: String("t"), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + }, + AccessTokensURL: String("atu"), + RepositoriesURL: String("ru"), + HTMLURL: String("hu"), + TargetType: String("tt"), + SingleFileName: String("sfn"), + RepositorySelection: String("rs"), + Events: []string{"e"}, + SingleFilePaths: []string{"s"}, + Permissions: &InstallationPermissions{ + Actions: String("a"), + Administration: String("ad"), + Checks: String("c"), + Contents: String("co"), + ContentReferences: String("cr"), + Deployments: String("d"), + Environments: String("e"), + Issues: String("i"), + Metadata: String("md"), + Members: String("m"), + OrganizationAdministration: String("oa"), + OrganizationHooks: String("oh"), + OrganizationPlan: String("op"), + OrganizationPreReceiveHooks: String("opr"), + OrganizationProjects: String("op"), + OrganizationSecrets: String("os"), + OrganizationSelfHostedRunners: String("osh"), + OrganizationUserBlocking: String("oub"), + Packages: String("pkg"), + Pages: String("pg"), + PullRequests: String("pr"), + RepositoryHooks: String("rh"), + RepositoryProjects: String("rp"), + RepositoryPreReceiveHooks: String("rprh"), + Secrets: String("s"), + SecretScanningAlerts: String("ssa"), + SecurityEvents: String("se"), + SingleFile: String("sf"), + Statuses: String("s"), + TeamDiscussions: String("td"), + VulnerabilityAlerts: String("va"), + Workflows: String("w"), + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + HasMultipleSingleFiles: Bool(false), + SuspendedBy: &User{ + Login: String("l"), + ID: Int64(1), + URL: String("u"), + AvatarURL: String("a"), + GravatarID: String("g"), + Name: String("n"), + Company: String("c"), + Blog: String("b"), + Location: String("l"), + Email: String("e"), + Hireable: Bool(true), + Bio: String("b"), + TwitterUsername: String("t"), + PublicRepos: Int(1), + Followers: Int(1), + Following: Int(1), + CreatedAt: &Timestamp{referenceTime}, + SuspendedAt: &Timestamp{referenceTime}, + }, + SuspendedAt: &Timestamp{referenceTime}, + }, + } + + want := `{ + "action": "a", + "environment": "e", + "deployment_callback_url": "b", + "deployment": { + "url": "url", + "id": 1, + "sha": "sha", + "ref": "ref", + "task": "t", + "payload": { + "key": "value" + }, + "environment": "e", + "description": "d", + "creator": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "statuses_url": "surl", + "repository_url": "rurl", + "node_id": "nid" + }, + "repository": { + "id": 1, + "name": "n", + "url": "s" + }, + "organization": { + "name": "n", + "company": "c", + "blog": "b", + "location": "loc", + "email": "e", + "twitter_username": "tu", + "description": "d", + "billing_email": "be", + "is_verified": true, + "has_organization_projects": true, + "has_repository_projects": true, + "default_repository_permission": "drp", + "members_can_create_repositories": true, + "members_can_create_public_repositories": false, + "members_can_create_private_repositories": true, + "members_can_create_internal_repositories": true, + "members_allowed_repository_creation_type": "marct", + "members_can_create_pages": true, + "members_can_create_public_pages": false, + "members_can_create_private_pages": true + }, + "pull_request": { + "id": 1 + }, + "sender": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "installation": { + "id": 1, + "node_id": "nid", + "app_id": 1, + "app_slug": "as", + "target_id": 1, + "account": { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "bio": "b", + "twitter_username": "t", + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "url": "u" + }, + "access_tokens_url": "atu", + "repositories_url": "ru", + "html_url": "hu", + "target_type": "tt", + "single_file_name": "sfn", + "repository_selection": "rs", + "events": [ + "e" + ], + "single_file_paths": [ + "s" + ], + "permissions": { + "actions": "a", + "administration": "ad", + "checks": "c", + "contents": "co", + "content_references": "cr", + "deployments": "d", + "environments": "e", + "issues": "i", + "metadata": "md", + "members": "m", + "organization_administration": "oa", + "organization_hooks": "oh", + "organization_plan": "op", + "organization_pre_receive_hooks": "opr", + "organization_projects": "op", + "organization_secrets": "os", + "organization_self_hosted_runners": "osh", + "organization_user_blocking": "oub", + "packages": "pkg", + "pages": "pg", + "pull_requests": "pr", + "repository_hooks": "rh", + "repository_projects": "rp", + "repository_pre_receive_hooks": "rprh", + "secrets": "s", + "secret_scanning_alerts": "ssa", + "security_events": "se", + "single_file": "sf", + "statuses": "s", + "team_discussions": "td", + "vulnerability_alerts": "va", + "workflows": "w" + }, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "has_multiple_single_files": false, + "suspended_by": { + "login": "l", + "id": 1, + "avatar_url": "a", + "gravatar_id": "g", + "name": "n", + "company": "c", + "blog": "b", + "location": "l", + "email": "e", + "hireable": true, + "bio": "b", + "twitter_username": "t", + "public_repos": 1, + "followers": 1, + "following": 1, + "created_at": ` + referenceTimeStr + `, + "suspended_at": ` + referenceTimeStr + `, + "url": "u" + }, + "suspended_at": ` + referenceTimeStr + ` + } + }` + + testJSONMarshal(t, u, want) +} + func TestDeploymentStatusEvent_Marshal(t *testing.T) { testJSONMarshal(t, &DeploymentStatusEvent{}, "{}") diff --git a/github/github-accessors.go b/github/github-accessors.go index 91743340536..c3dba9ccf6c 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4614,6 +4614,78 @@ func (d *DeploymentEvent) GetSender() *User { return d.Sender } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (d *DeploymentProtectionRuleEvent) GetAction() string { + if d == nil || d.Action == nil { + return "" + } + return *d.Action +} + +// GetDeployment returns the Deployment field. +func (d *DeploymentProtectionRuleEvent) GetDeployment() *Deployment { + if d == nil { + return nil + } + return d.Deployment +} + +// GetDeploymentCallbackURL returns the DeploymentCallbackURL field if it's non-nil, zero value otherwise. +func (d *DeploymentProtectionRuleEvent) GetDeploymentCallbackURL() string { + if d == nil || d.DeploymentCallbackURL == nil { + return "" + } + return *d.DeploymentCallbackURL +} + +// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. +func (d *DeploymentProtectionRuleEvent) GetEnvironment() string { + if d == nil || d.Environment == nil { + return "" + } + return *d.Environment +} + +// GetInstallation returns the Installation field. +func (d *DeploymentProtectionRuleEvent) GetInstallation() *Installation { + if d == nil { + return nil + } + return d.Installation +} + +// GetOrganization returns the Organization field. +func (d *DeploymentProtectionRuleEvent) GetOrganization() *Organization { + if d == nil { + return nil + } + return d.Organization +} + +// GetPullRequest returns the PullRequest field. +func (d *DeploymentProtectionRuleEvent) GetPullRequest() *PullRequest { + if d == nil { + return nil + } + return d.PullRequest +} + +// GetRepo returns the Repo field. +func (d *DeploymentProtectionRuleEvent) GetRepo() *Repository { + if d == nil { + return nil + } + return d.Repo +} + +// GetSender returns the Sender field. +func (d *DeploymentProtectionRuleEvent) GetSender() *User { + if d == nil { + return nil + } + return d.Sender +} + // GetAutoMerge returns the AutoMerge field if it's non-nil, zero value otherwise. func (d *DeploymentRequest) GetAutoMerge() bool { if d == nil || d.AutoMerge == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 8f7292d7b04..f3ad4685b6c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -5399,6 +5399,78 @@ func TestDeploymentEvent_GetSender(tt *testing.T) { d.GetSender() } +func TestDeploymentProtectionRuleEvent_GetAction(tt *testing.T) { + var zeroValue string + d := &DeploymentProtectionRuleEvent{Action: &zeroValue} + d.GetAction() + d = &DeploymentProtectionRuleEvent{} + d.GetAction() + d = nil + d.GetAction() +} + +func TestDeploymentProtectionRuleEvent_GetDeployment(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetDeployment() + d = nil + d.GetDeployment() +} + +func TestDeploymentProtectionRuleEvent_GetDeploymentCallbackURL(tt *testing.T) { + var zeroValue string + d := &DeploymentProtectionRuleEvent{DeploymentCallbackURL: &zeroValue} + d.GetDeploymentCallbackURL() + d = &DeploymentProtectionRuleEvent{} + d.GetDeploymentCallbackURL() + d = nil + d.GetDeploymentCallbackURL() +} + +func TestDeploymentProtectionRuleEvent_GetEnvironment(tt *testing.T) { + var zeroValue string + d := &DeploymentProtectionRuleEvent{Environment: &zeroValue} + d.GetEnvironment() + d = &DeploymentProtectionRuleEvent{} + d.GetEnvironment() + d = nil + d.GetEnvironment() +} + +func TestDeploymentProtectionRuleEvent_GetInstallation(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetInstallation() + d = nil + d.GetInstallation() +} + +func TestDeploymentProtectionRuleEvent_GetOrganization(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetOrganization() + d = nil + d.GetOrganization() +} + +func TestDeploymentProtectionRuleEvent_GetPullRequest(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetPullRequest() + d = nil + d.GetPullRequest() +} + +func TestDeploymentProtectionRuleEvent_GetRepo(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetRepo() + d = nil + d.GetRepo() +} + +func TestDeploymentProtectionRuleEvent_GetSender(tt *testing.T) { + d := &DeploymentProtectionRuleEvent{} + d.GetSender() + d = nil + d.GetSender() +} + func TestDeploymentRequest_GetAutoMerge(tt *testing.T) { var zeroValue bool d := &DeploymentRequest{AutoMerge: &zeroValue} diff --git a/github/messages.go b/github/messages.go index 925e73e9a67..660e5a42c31 100644 --- a/github/messages.go +++ b/github/messages.go @@ -55,6 +55,7 @@ var ( "deploy_key": "DeployKeyEvent", "deployment": "DeploymentEvent", "deployment_status": "DeploymentStatusEvent", + "deployment_protection_rule": "DeploymentProtectionRule", "discussion": "DiscussionEvent", "discussion_comment": "DiscussionCommentEvent", "fork": "ForkEvent", From 6ead38dcf6c756597f064c1478400b0164136ecc Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Thu, 27 Apr 2023 14:31:46 -0400 Subject: [PATCH 2/5] Add messages.go test --- github/messages_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/github/messages_test.go b/github/messages_test.go index 04f29420402..8dbb0fdf996 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -292,6 +292,10 @@ func TestParseWebHook(t *testing.T) { payload: &DeploymentEvent{}, messageType: "deployment", }, + { + payload: &DeploymentProtectionRuleEvent{}, + messageType: "deployment_protection_rule", + }, { payload: &DeploymentStatusEvent{}, messageType: "deployment_status", From b19d61ef52bb36b0c1a032fcc74ab4ab82a61436 Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Thu, 27 Apr 2023 15:05:10 -0400 Subject: [PATCH 3/5] Apply suggestions from code review Thanks for catching all of my misses. Much appreciated :) I'll run a follow-up `go generate` command after committing your suggestions. Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/event.go | 2 +- github/event_types.go | 8 ++++---- github/messages.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/github/event.go b/github/event.go index 7ad1cfc89da..20907a99321 100644 --- a/github/event.go +++ b/github/event.go @@ -49,7 +49,7 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &DeployKeyEvent{} case "DeploymentEvent": payload = &DeploymentEvent{} - case "DeploymentProtectionRule": + case "DeploymentProtectionRuleEvent": payload = &DeploymentProtectionRuleEvent{} case "DeploymentStatusEvent": payload = &DeploymentStatusEvent{} diff --git a/github/event_types.go b/github/event_types.go index c8eb23e4da2..452cac75be9 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -173,20 +173,20 @@ type DeploymentEvent struct { Installation *Installation `json:"installation,omitempty"` } -// DeploymentProtectionRuleEvent represents a deployment protection rule -// The Webhook even name is "deployment_protection_rule". +// DeploymentProtectionRuleEvent represents a deployment protection rule event. +// The Webhook event name is "deployment_protection_rule". // // GitHub API docs: https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#deployment_protection_rule type DeploymentProtectionRuleEvent struct { Action *string `json:"action,omitempty"` Environment *string `json:"environment,omitempty"` - +Event *string `json:"event,omitempty"` // The URL Github provides for a third-party to use in order to pass/fail a deployment gate DeploymentCallbackURL *string `json:"deployment_callback_url,omitempty"` Deployment *Deployment `json:"deployment,omitempty"` Repo *Repository `json:"repository,omitempty"` Organization *Organization `json:"organization,omitempty"` - PullRequest *PullRequest `json:"pull_request,omitempty"` + PullRequests []*PullRequest `json:"pull_requests,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } diff --git a/github/messages.go b/github/messages.go index 660e5a42c31..8547b8810f8 100644 --- a/github/messages.go +++ b/github/messages.go @@ -55,7 +55,7 @@ var ( "deploy_key": "DeployKeyEvent", "deployment": "DeploymentEvent", "deployment_status": "DeploymentStatusEvent", - "deployment_protection_rule": "DeploymentProtectionRule", + "deployment_protection_rule": "DeploymentProtectionRuleEvent", "discussion": "DiscussionEvent", "discussion_comment": "DiscussionCommentEvent", "fork": "ForkEvent", From c2acbfda3078c90cd02d55c78e378499746d722a Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Thu, 27 Apr 2023 15:14:33 -0400 Subject: [PATCH 4/5] Update tests after suggestions --- github/event_types_test.go | 54 ++++++++++++++++++++++++++++++--- github/github-accessors.go | 16 +++++----- github/github-accessors_test.go | 17 ++++++----- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/github/event_types_test.go b/github/event_types_test.go index 5c1fbf2eda2..db284036e3f 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -5546,7 +5546,31 @@ func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { MembersCanCreatePublicPages: Bool(false), MembersCanCreatePrivatePages: Bool(true), }, - PullRequest: &PullRequest{ID: Int64(1)}, + PullRequests: []*PullRequest{ + { + URL: String("u"), + ID: Int64(1), + Number: Int(1), + Head: &PullRequestBranch{ + Ref: String("r"), + SHA: String("s"), + Repo: &Repository{ + ID: Int64(1), + URL: String("s"), + Name: String("n"), + }, + }, + Base: &PullRequestBranch{ + Ref: String("r"), + SHA: String("s"), + Repo: &Repository{ + ID: Int64(1), + URL: String("u"), + Name: String("n"), + }, + }, + }, + }, Sender: &User{ Login: String("l"), ID: Int64(1), @@ -5708,9 +5732,31 @@ func TestDeploymentProtectionRuleEvent_Marshal(t *testing.T) { "members_can_create_public_pages": false, "members_can_create_private_pages": true }, - "pull_request": { - "id": 1 - }, + "pull_requests": [ + { + "id": 1, + "number": 1, + "url": "u", + "head": { + "ref": "r", + "sha": "s", + "repo": { + "id": 1, + "name": "n", + "url": "s" + } + }, + "base": { + "ref": "r", + "sha": "s", + "repo": { + "id": 1, + "name": "n", + "url": "u" + } + } + } + ], "sender": { "login": "l", "id": 1, diff --git a/github/github-accessors.go b/github/github-accessors.go index c3dba9ccf6c..7fa63d8f4b0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4646,6 +4646,14 @@ func (d *DeploymentProtectionRuleEvent) GetEnvironment() string { return *d.Environment } +// GetEvent returns the Event field if it's non-nil, zero value otherwise. +func (d *DeploymentProtectionRuleEvent) GetEvent() string { + if d == nil || d.Event == nil { + return "" + } + return *d.Event +} + // GetInstallation returns the Installation field. func (d *DeploymentProtectionRuleEvent) GetInstallation() *Installation { if d == nil { @@ -4662,14 +4670,6 @@ func (d *DeploymentProtectionRuleEvent) GetOrganization() *Organization { return d.Organization } -// GetPullRequest returns the PullRequest field. -func (d *DeploymentProtectionRuleEvent) GetPullRequest() *PullRequest { - if d == nil { - return nil - } - return d.PullRequest -} - // GetRepo returns the Repo field. func (d *DeploymentProtectionRuleEvent) GetRepo() *Repository { if d == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index f3ad4685b6c..d64b9fa3969 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -5436,6 +5436,16 @@ func TestDeploymentProtectionRuleEvent_GetEnvironment(tt *testing.T) { d.GetEnvironment() } +func TestDeploymentProtectionRuleEvent_GetEvent(tt *testing.T) { + var zeroValue string + d := &DeploymentProtectionRuleEvent{Event: &zeroValue} + d.GetEvent() + d = &DeploymentProtectionRuleEvent{} + d.GetEvent() + d = nil + d.GetEvent() +} + func TestDeploymentProtectionRuleEvent_GetInstallation(tt *testing.T) { d := &DeploymentProtectionRuleEvent{} d.GetInstallation() @@ -5450,13 +5460,6 @@ func TestDeploymentProtectionRuleEvent_GetOrganization(tt *testing.T) { d.GetOrganization() } -func TestDeploymentProtectionRuleEvent_GetPullRequest(tt *testing.T) { - d := &DeploymentProtectionRuleEvent{} - d.GetPullRequest() - d = nil - d.GetPullRequest() -} - func TestDeploymentProtectionRuleEvent_GetRepo(tt *testing.T) { d := &DeploymentProtectionRuleEvent{} d.GetRepo() From cd5c10f53828034d57e96f56489f809215064425 Mon Sep 17 00:00:00 2001 From: Bo Huang Date: Thu, 27 Apr 2023 15:19:47 -0400 Subject: [PATCH 5/5] run gofmt --- github/event_types.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 452cac75be9..6a13b286bd2 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -180,15 +180,16 @@ type DeploymentEvent struct { type DeploymentProtectionRuleEvent struct { Action *string `json:"action,omitempty"` Environment *string `json:"environment,omitempty"` -Event *string `json:"event,omitempty"` + Event *string `json:"event,omitempty"` + // The URL Github provides for a third-party to use in order to pass/fail a deployment gate - DeploymentCallbackURL *string `json:"deployment_callback_url,omitempty"` - Deployment *Deployment `json:"deployment,omitempty"` - Repo *Repository `json:"repository,omitempty"` - Organization *Organization `json:"organization,omitempty"` - PullRequests []*PullRequest `json:"pull_requests,omitempty"` - Sender *User `json:"sender,omitempty"` - Installation *Installation `json:"installation,omitempty"` + DeploymentCallbackURL *string `json:"deployment_callback_url,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Organization *Organization `json:"organization,omitempty"` + PullRequests []*PullRequest `json:"pull_requests,omitempty"` + Sender *User `json:"sender,omitempty"` + Installation *Installation `json:"installation,omitempty"` } // DeploymentStatusEvent represents a deployment status.