Skip to content

Commit

Permalink
Add missing common event fields.
Browse files Browse the repository at this point in the history
See
https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#webhook-payload-object-common-properties
for the list of common fields.

I may have missed some - but gives better coverage for fields we were
missing before.

Signed-off-by: Billy Lynch <billy@chainguard.dev>
  • Loading branch information
wlynch committed Jun 15, 2022
1 parent 3072c0a commit d045eda
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 5 deletions.
20 changes: 15 additions & 5 deletions github/event_types.go
Expand Up @@ -106,10 +106,11 @@ type CreateEvent struct {
RefType *string `json:"ref_type,omitempty"`
MasterBranch *string `json:"master_branch,omitempty"`
Description *string `json:"description,omitempty"`
PusherType *string `json:"pusher_type,omitempty"`

// The following fields are only populated by Webhook events.
PusherType *string `json:"pusher_type,omitempty"`
Repo *Repository `json:"repository,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}
Expand Down Expand Up @@ -493,13 +494,14 @@ type IssuesEvent struct {
type LabelEvent struct {
// Action is the action that was performed. Possible values are:
// "created", "edited", "deleted"
Action *string `json:"action,omitempty"`
Label *Label `json:"label,omitempty"`
Action *string `json:"action,omitempty"`
Label *Label `json:"label,omitempty"`
Changes *EditChange `json:"changes,omitempty"`

// The following fields are only populated by Webhook events.
Changes *EditChange `json:"changes,omitempty"`
Repo *Repository `json:"repository,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}

Expand Down Expand Up @@ -574,6 +576,9 @@ type MetaEvent struct {
Hook *Hook `json:"hook,omitempty"`

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

Expand Down Expand Up @@ -682,7 +687,12 @@ type PingEvent struct {
// The ID of the webhook that triggered the ping.
HookID *int64 `json:"hook_id,omitempty"`
// The webhook configuration.
Hook *Hook `json:"hook,omitempty"`
Hook *Hook `json:"hook,omitempty"`

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

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

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

56 changes: 56 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 d045eda

Please sign in to comment.