Skip to content

Commit

Permalink
Add Repo and Org fields to DeployKeyEvent (#2280)
Browse files Browse the repository at this point in the history
Fixes: #2279.
  • Loading branch information
IainSteers committed Feb 3, 2022
1 parent e1c28bc commit 3c43a10
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
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.

0 comments on commit 3c43a10

Please sign in to comment.