Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Repo and Org fields to DeployKeyEvent #2280

Merged
merged 2 commits into from Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions github/event_types.go
Expand Up @@ -145,7 +145,15 @@ type DeployKeyEvent struct {
// The deploy key resource.
Key *Key `json:"key,omitempty"`

// The Repository where the event occurred
Repo *Repository `json:"repository,omitempty"`

// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Organization *Organization `json:"organization,omitempty"`

// The following fields are only populated by Webhook events.
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}

Expand Down
72 changes: 72 additions & 0 deletions github/event_types_test.go
Expand Up @@ -10220,6 +10220,42 @@ func TestDeployKeyEvent_Marshal(t *testing.T) {
Verified: Bool(false),
CreatedAt: &Timestamp{referenceTime},
},
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),
},
Sender: &User{
Login: String("l"),
ID: Int64(1),
NodeID: String("n"),
AvatarURL: String("a"),
URL: String("u"),
EventsURL: String("e"),
ReposURL: String("r"),
},
}

want := `{
Expand All @@ -10232,6 +10268,42 @@ func TestDeployKeyEvent_Marshal(t *testing.T) {
"read_only": false,
"verified": false,
"created_at": ` + referenceTimeStr + `
},
"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
},
"sender": {
"login": "l",
"id": 1,
"node_id": "n",
"avatar_url": "a",
"url": "u",
"events_url": "e",
"repos_url": "r"
}
}`

Expand Down
24 changes: 24 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.