From b7da72eec5e4a8d560407680becfaee31c1eb054 Mon Sep 17 00:00:00 2001 From: nxya Date: Sun, 9 Jul 2023 20:34:24 -0400 Subject: [PATCH 1/2] Implemented installation_target webhook --- github/event.go | 2 + github/event_types.go | 32 +++ github/event_types_test.go | 336 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 104 ++++++++++ github/github-accessors_test.go | 103 ++++++++++ github/messages.go | 1 + github/messages_test.go | 4 + 7 files changed, 582 insertions(+) diff --git a/github/event.go b/github/event.go index 4ee25603a83..7100bf6e6f1 100644 --- a/github/event.go +++ b/github/event.go @@ -67,6 +67,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &InstallationEvent{} case "InstallationRepositoriesEvent": payload = &InstallationRepositoriesEvent{} + case "InstallationTargetEvent": + payload = &InstallationTargetEvent{} case "IssueCommentEvent": payload = &IssueCommentEvent{} case "IssuesEvent": diff --git a/github/event_types.go b/github/event_types.go index 6a13b286bd2..8ccf176f421 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -505,6 +505,38 @@ type InstallationRepositoriesEvent struct { Installation *Installation `json:"installation,omitempty"` } +// Change in login +type Login struct { + From *string `json:"from,omitempty"` +} + +// Change in slug +type Slug struct { + From *string `json:"from,omitempty"` +} + +// Changes represents a change in slug or login +type Changes struct { + Login *Login `json:"login,omitempty"` + Slug *Slug `json:"slug,omitempty"` +} + +// InstallationTargetEvent is triggered when there is activity on an installation from a user or organization account. +// The Webhook event name is "installation_target". +// +// GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target +type InstallationTargetEvent struct { + Account *User `json:"account,omitempty"` + Action *string `json:"action,omitempty"` + Changes *Changes `json:"changes,omitempty"` + Enterprise *Enterprise `json:"enterprise,omitempty"` + Installation *Installation `json:"installation,omitempty"` + Organization *Organization `json:"organization,omitempty"` + Repository *Repository `json:"repository,omitempty"` + Sender *User `json:"sender,omitempty"` + TargetType *string `json:"target_type,omitempty"` +} + // IssueCommentEvent is triggered when an issue comment is created on an issue // or pull request. // The Webhook event name is "issue_comment". diff --git a/github/event_types_test.go b/github/event_types_test.go index db284036e3f..607f6ccf204 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -1332,6 +1332,342 @@ func TestInstallationRepositoriesEvent_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } +func TestInstallationTargetEvent_Marshal(t *testing.T) { + testJSONMarshal(t, &InstallationTargetEvent{}, "{}") + + u := &InstallationTargetEvent{ + Account: &User{ + Login: String("u"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("l"), + }, + Action: String("a"), + Changes: &Changes{ + Login: &Login{ + From: String("p"), + }, + Slug: &Slug{ + From: String("j"), + }, + }, + Enterprise: &Enterprise{ + ID: Int(1), + Slug: String("s"), + Name: String("n"), + NodeID: String("nid"), + AvatarURL: String("au"), + Description: String("d"), + WebsiteURL: String("wu"), + HTMLURL: String("hu"), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + }, + 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}, + }, + 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), + }, + Repository: &Repository{ + ID: Int64(1), + URL: String("s"), + Name: String("n"), + }, + Sender: &User{ + Login: String("l"), + ID: Int64(1), + NodeID: String("n"), + URL: String("u"), + ReposURL: String("r"), + EventsURL: String("e"), + AvatarURL: String("a"), + }, + TargetType: String("running"), + } + + want := `{ + "account": { + "login": "u", + "id": 1, + "node_id": "n", + "avatar_url": "l", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "action": "a", + "changes": { + "login": { + "from": "p" + }, + "slug": { + "from": "j" + } + }, + "enterprise": { + "id": 1, + "slug": "s", + "name": "n", + "node_id": "nid", + "avatar_url": "au", + "description": "d", + "website_url": "wu", + "html_url": "hu", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + ` + }, + "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 + ` + }, + "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 + }, + "repository": { + "id": 1, + "url": "s", + "name": "n" + }, + "sender": { + "login": "l", + "id": 1, + "node_id": "n", + "avatar_url": "a", + "url": "u", + "events_url": "e", + "repos_url": "r" + }, + "target_type": "running" + }` + + testJSONMarshal(t, u, want) +} + func TestEditTitle_Marshal(t *testing.T) { testJSONMarshal(t, &EditTitle{}, "{}") diff --git a/github/github-accessors.go b/github/github-accessors.go index 41cd582c1a1..51c4532abea 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -2238,6 +2238,22 @@ func (b *BypassActor) GetActorType() string { return *b.ActorType } +// GetLogin returns the Login field. +func (c *Changes) GetLogin() *Login { + if c == nil { + return nil + } + return c.Login +} + +// GetSlug returns the Slug field. +func (c *Changes) GetSlug() *Slug { + if c == nil { + return nil + } + return c.Slug +} + // GetApp returns the App field. func (c *CheckRun) GetApp() *App { if c == nil { @@ -8390,6 +8406,78 @@ func (i *InstallationRepositoriesEvent) GetSender() *User { return i.Sender } +// GetAccount returns the Account field. +func (i *InstallationTargetEvent) GetAccount() *User { + if i == nil { + return nil + } + return i.Account +} + +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (i *InstallationTargetEvent) GetAction() string { + if i == nil || i.Action == nil { + return "" + } + return *i.Action +} + +// GetChanges returns the Changes field. +func (i *InstallationTargetEvent) GetChanges() *Changes { + if i == nil { + return nil + } + return i.Changes +} + +// GetEnterprise returns the Enterprise field. +func (i *InstallationTargetEvent) GetEnterprise() *Enterprise { + if i == nil { + return nil + } + return i.Enterprise +} + +// GetInstallation returns the Installation field. +func (i *InstallationTargetEvent) GetInstallation() *Installation { + if i == nil { + return nil + } + return i.Installation +} + +// GetOrganization returns the Organization field. +func (i *InstallationTargetEvent) GetOrganization() *Organization { + if i == nil { + return nil + } + return i.Organization +} + +// GetRepository returns the Repository field. +func (i *InstallationTargetEvent) GetRepository() *Repository { + if i == nil { + return nil + } + return i.Repository +} + +// GetSender returns the Sender field. +func (i *InstallationTargetEvent) GetSender() *User { + if i == nil { + return nil + } + return i.Sender +} + +// GetTargetType returns the TargetType field if it's non-nil, zero value otherwise. +func (i *InstallationTargetEvent) GetTargetType() string { + if i == nil || i.TargetType == nil { + return "" + } + return *i.TargetType +} + // GetExpiresAt returns the ExpiresAt field if it's non-nil, zero value otherwise. func (i *InstallationToken) GetExpiresAt() Timestamp { if i == nil || i.ExpiresAt == nil { @@ -10038,6 +10126,14 @@ func (l *LockBranch) GetEnabled() bool { return *l.Enabled } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (l *Login) GetFrom() string { + if l == nil || l.From == nil { + return "" + } + return *l.From +} + // GetEffectiveDate returns the EffectiveDate field if it's non-nil, zero value otherwise. func (m *MarketplacePendingChange) GetEffectiveDate() Timestamp { if m == nil || m.EffectiveDate == nil { @@ -19918,6 +20014,14 @@ func (s *SignatureVerification) GetVerified() bool { return *s.Verified } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (s *Slug) GetFrom() string { + if s == nil || s.From == nil { + return "" + } + return *s.From +} + // GetActor returns the Actor field. func (s *Source) GetActor() *User { if s == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 993a12484b9..2fcaf803977 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2684,6 +2684,20 @@ func TestBypassActor_GetActorType(tt *testing.T) { b.GetActorType() } +func TestChanges_GetLogin(tt *testing.T) { + c := &Changes{} + c.GetLogin() + c = nil + c.GetLogin() +} + +func TestChanges_GetSlug(tt *testing.T) { + c := &Changes{} + c.GetSlug() + c = nil + c.GetSlug() +} + func TestCheckRun_GetApp(tt *testing.T) { c := &CheckRun{} c.GetApp() @@ -9873,6 +9887,75 @@ func TestInstallationRepositoriesEvent_GetSender(tt *testing.T) { i.GetSender() } +func TestInstallationTargetEvent_GetAccount(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetAccount() + i = nil + i.GetAccount() +} + +func TestInstallationTargetEvent_GetAction(tt *testing.T) { + var zeroValue string + i := &InstallationTargetEvent{Action: &zeroValue} + i.GetAction() + i = &InstallationTargetEvent{} + i.GetAction() + i = nil + i.GetAction() +} + +func TestInstallationTargetEvent_GetChanges(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetChanges() + i = nil + i.GetChanges() +} + +func TestInstallationTargetEvent_GetEnterprise(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetEnterprise() + i = nil + i.GetEnterprise() +} + +func TestInstallationTargetEvent_GetInstallation(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetInstallation() + i = nil + i.GetInstallation() +} + +func TestInstallationTargetEvent_GetOrganization(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetOrganization() + i = nil + i.GetOrganization() +} + +func TestInstallationTargetEvent_GetRepository(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetRepository() + i = nil + i.GetRepository() +} + +func TestInstallationTargetEvent_GetSender(tt *testing.T) { + i := &InstallationTargetEvent{} + i.GetSender() + i = nil + i.GetSender() +} + +func TestInstallationTargetEvent_GetTargetType(tt *testing.T) { + var zeroValue string + i := &InstallationTargetEvent{TargetType: &zeroValue} + i.GetTargetType() + i = &InstallationTargetEvent{} + i.GetTargetType() + i = nil + i.GetTargetType() +} + func TestInstallationToken_GetExpiresAt(tt *testing.T) { var zeroValue Timestamp i := &InstallationToken{ExpiresAt: &zeroValue} @@ -11795,6 +11878,16 @@ func TestLockBranch_GetEnabled(tt *testing.T) { l.GetEnabled() } +func TestLogin_GetFrom(tt *testing.T) { + var zeroValue string + l := &Login{From: &zeroValue} + l.GetFrom() + l = &Login{} + l.GetFrom() + l = nil + l.GetFrom() +} + func TestMarketplacePendingChange_GetEffectiveDate(tt *testing.T) { var zeroValue Timestamp m := &MarketplacePendingChange{EffectiveDate: &zeroValue} @@ -23263,6 +23356,16 @@ func TestSignatureVerification_GetVerified(tt *testing.T) { s.GetVerified() } +func TestSlug_GetFrom(tt *testing.T) { + var zeroValue string + s := &Slug{From: &zeroValue} + s.GetFrom() + s = &Slug{} + s.GetFrom() + s = nil + s.GetFrom() +} + func TestSource_GetActor(tt *testing.T) { s := &Source{} s.GetActor() diff --git a/github/messages.go b/github/messages.go index bb5ae3f3895..a348818abb5 100644 --- a/github/messages.go +++ b/github/messages.go @@ -63,6 +63,7 @@ var ( "gollum": "GollumEvent", "installation": "InstallationEvent", "installation_repositories": "InstallationRepositoriesEvent", + "installation_target": "InstallationTargetEvent", "issue_comment": "IssueCommentEvent", "issues": "IssuesEvent", "label": "LabelEvent", diff --git a/github/messages_test.go b/github/messages_test.go index 80fb3e5ff54..064e01c282b 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -328,6 +328,10 @@ func TestParseWebHook(t *testing.T) { payload: &InstallationRepositoriesEvent{}, messageType: "installation_repositories", }, + { + payload: &InstallationTargetEvent{}, + messageType: "installation_target", + }, { payload: &IssueCommentEvent{}, messageType: "issue_comment", From fbdb75aa4a8ce8d443ebf4a7f38aafde20f48774 Mon Sep 17 00:00:00 2001 From: nxya Date: Sun, 9 Jul 2023 21:28:32 -0400 Subject: [PATCH 2/2] Update struct types to be specific to InstallationTarget --- github/event_types.go | 34 ++++++++--------- github/event_types_test.go | 6 +-- github/github-accessors.go | 66 ++++++++++++++++---------------- github/github-accessors_test.go | 68 ++++++++++++++++----------------- 4 files changed, 87 insertions(+), 87 deletions(-) diff --git a/github/event_types.go b/github/event_types.go index 8ccf176f421..d915539039b 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -505,20 +505,20 @@ type InstallationRepositoriesEvent struct { Installation *Installation `json:"installation,omitempty"` } -// Change in login -type Login struct { +// InstallationLoginChange represents a change in login on an installation. +type InstallationLoginChange struct { From *string `json:"from,omitempty"` } -// Change in slug -type Slug struct { +// InstallationSlugChange represents a change in slug on an installation. +type InstallationSlugChange struct { From *string `json:"from,omitempty"` } -// Changes represents a change in slug or login -type Changes struct { - Login *Login `json:"login,omitempty"` - Slug *Slug `json:"slug,omitempty"` +// InstallationChanges represents a change in slug or login on an installation. +type InstallationChanges struct { + Login *InstallationLoginChange `json:"login,omitempty"` + Slug *InstallationSlugChange `json:"slug,omitempty"` } // InstallationTargetEvent is triggered when there is activity on an installation from a user or organization account. @@ -526,15 +526,15 @@ type Changes struct { // // GitHub API docs: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_target type InstallationTargetEvent struct { - Account *User `json:"account,omitempty"` - Action *string `json:"action,omitempty"` - Changes *Changes `json:"changes,omitempty"` - Enterprise *Enterprise `json:"enterprise,omitempty"` - Installation *Installation `json:"installation,omitempty"` - Organization *Organization `json:"organization,omitempty"` - Repository *Repository `json:"repository,omitempty"` - Sender *User `json:"sender,omitempty"` - TargetType *string `json:"target_type,omitempty"` + Account *User `json:"account,omitempty"` + Action *string `json:"action,omitempty"` + Changes *InstallationChanges `json:"changes,omitempty"` + Enterprise *Enterprise `json:"enterprise,omitempty"` + Installation *Installation `json:"installation,omitempty"` + Organization *Organization `json:"organization,omitempty"` + Repository *Repository `json:"repository,omitempty"` + Sender *User `json:"sender,omitempty"` + TargetType *string `json:"target_type,omitempty"` } // IssueCommentEvent is triggered when an issue comment is created on an issue diff --git a/github/event_types_test.go b/github/event_types_test.go index 607f6ccf204..cf4a089ff94 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -1346,11 +1346,11 @@ func TestInstallationTargetEvent_Marshal(t *testing.T) { AvatarURL: String("l"), }, Action: String("a"), - Changes: &Changes{ - Login: &Login{ + Changes: &InstallationChanges{ + Login: &InstallationLoginChange{ From: String("p"), }, - Slug: &Slug{ + Slug: &InstallationSlugChange{ From: String("j"), }, }, diff --git a/github/github-accessors.go b/github/github-accessors.go index 51c4532abea..b9fcee8e859 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -2238,22 +2238,6 @@ func (b *BypassActor) GetActorType() string { return *b.ActorType } -// GetLogin returns the Login field. -func (c *Changes) GetLogin() *Login { - if c == nil { - return nil - } - return c.Login -} - -// GetSlug returns the Slug field. -func (c *Changes) GetSlug() *Slug { - if c == nil { - return nil - } - return c.Slug -} - // GetApp returns the App field. func (c *CheckRun) GetApp() *App { if c == nil { @@ -8046,6 +8030,22 @@ func (i *Installation) GetUpdatedAt() Timestamp { return *i.UpdatedAt } +// GetLogin returns the Login field. +func (i *InstallationChanges) GetLogin() *InstallationLoginChange { + if i == nil { + return nil + } + return i.Login +} + +// GetSlug returns the Slug field. +func (i *InstallationChanges) GetSlug() *InstallationSlugChange { + if i == nil { + return nil + } + return i.Slug +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (i *InstallationEvent) GetAction() string { if i == nil || i.Action == nil { @@ -8078,6 +8078,14 @@ func (i *InstallationEvent) GetSender() *User { return i.Sender } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (i *InstallationLoginChange) GetFrom() string { + if i == nil || i.From == nil { + return "" + } + return *i.From +} + // GetActions returns the Actions field if it's non-nil, zero value otherwise. func (i *InstallationPermissions) GetActions() string { if i == nil || i.Actions == nil { @@ -8406,6 +8414,14 @@ func (i *InstallationRepositoriesEvent) GetSender() *User { return i.Sender } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (i *InstallationSlugChange) GetFrom() string { + if i == nil || i.From == nil { + return "" + } + return *i.From +} + // GetAccount returns the Account field. func (i *InstallationTargetEvent) GetAccount() *User { if i == nil { @@ -8423,7 +8439,7 @@ func (i *InstallationTargetEvent) GetAction() string { } // GetChanges returns the Changes field. -func (i *InstallationTargetEvent) GetChanges() *Changes { +func (i *InstallationTargetEvent) GetChanges() *InstallationChanges { if i == nil { return nil } @@ -10126,14 +10142,6 @@ func (l *LockBranch) GetEnabled() bool { return *l.Enabled } -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (l *Login) GetFrom() string { - if l == nil || l.From == nil { - return "" - } - return *l.From -} - // GetEffectiveDate returns the EffectiveDate field if it's non-nil, zero value otherwise. func (m *MarketplacePendingChange) GetEffectiveDate() Timestamp { if m == nil || m.EffectiveDate == nil { @@ -20014,14 +20022,6 @@ func (s *SignatureVerification) GetVerified() bool { return *s.Verified } -// GetFrom returns the From field if it's non-nil, zero value otherwise. -func (s *Slug) GetFrom() string { - if s == nil || s.From == nil { - return "" - } - return *s.From -} - // GetActor returns the Actor field. func (s *Source) GetActor() *User { if s == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2fcaf803977..dd9a53c693a 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2684,20 +2684,6 @@ func TestBypassActor_GetActorType(tt *testing.T) { b.GetActorType() } -func TestChanges_GetLogin(tt *testing.T) { - c := &Changes{} - c.GetLogin() - c = nil - c.GetLogin() -} - -func TestChanges_GetSlug(tt *testing.T) { - c := &Changes{} - c.GetSlug() - c = nil - c.GetSlug() -} - func TestCheckRun_GetApp(tt *testing.T) { c := &CheckRun{} c.GetApp() @@ -9452,6 +9438,20 @@ func TestInstallation_GetUpdatedAt(tt *testing.T) { i.GetUpdatedAt() } +func TestInstallationChanges_GetLogin(tt *testing.T) { + i := &InstallationChanges{} + i.GetLogin() + i = nil + i.GetLogin() +} + +func TestInstallationChanges_GetSlug(tt *testing.T) { + i := &InstallationChanges{} + i.GetSlug() + i = nil + i.GetSlug() +} + func TestInstallationEvent_GetAction(tt *testing.T) { var zeroValue string i := &InstallationEvent{Action: &zeroValue} @@ -9483,6 +9483,16 @@ func TestInstallationEvent_GetSender(tt *testing.T) { i.GetSender() } +func TestInstallationLoginChange_GetFrom(tt *testing.T) { + var zeroValue string + i := &InstallationLoginChange{From: &zeroValue} + i.GetFrom() + i = &InstallationLoginChange{} + i.GetFrom() + i = nil + i.GetFrom() +} + func TestInstallationPermissions_GetActions(tt *testing.T) { var zeroValue string i := &InstallationPermissions{Actions: &zeroValue} @@ -9887,6 +9897,16 @@ func TestInstallationRepositoriesEvent_GetSender(tt *testing.T) { i.GetSender() } +func TestInstallationSlugChange_GetFrom(tt *testing.T) { + var zeroValue string + i := &InstallationSlugChange{From: &zeroValue} + i.GetFrom() + i = &InstallationSlugChange{} + i.GetFrom() + i = nil + i.GetFrom() +} + func TestInstallationTargetEvent_GetAccount(tt *testing.T) { i := &InstallationTargetEvent{} i.GetAccount() @@ -11878,16 +11898,6 @@ func TestLockBranch_GetEnabled(tt *testing.T) { l.GetEnabled() } -func TestLogin_GetFrom(tt *testing.T) { - var zeroValue string - l := &Login{From: &zeroValue} - l.GetFrom() - l = &Login{} - l.GetFrom() - l = nil - l.GetFrom() -} - func TestMarketplacePendingChange_GetEffectiveDate(tt *testing.T) { var zeroValue Timestamp m := &MarketplacePendingChange{EffectiveDate: &zeroValue} @@ -23356,16 +23366,6 @@ func TestSignatureVerification_GetVerified(tt *testing.T) { s.GetVerified() } -func TestSlug_GetFrom(tt *testing.T) { - var zeroValue string - s := &Slug{From: &zeroValue} - s.GetFrom() - s = &Slug{} - s.GetFrom() - s = nil - s.GetFrom() -} - func TestSource_GetActor(tt *testing.T) { s := &Source{} s.GetActor()