Merge pull request #86 from BlizzTom/v5
Adding support for github event integration_installation_repositories
This commit is contained in:
+40
-39
@@ -28,44 +28,45 @@ type Event string
|
|||||||
|
|
||||||
// GitHub hook types
|
// GitHub hook types
|
||||||
const (
|
const (
|
||||||
CheckRunEvent Event = "check_run"
|
CheckRunEvent Event = "check_run"
|
||||||
CheckSuiteEvent Event = "check_suite"
|
CheckSuiteEvent Event = "check_suite"
|
||||||
CommitCommentEvent Event = "commit_comment"
|
CommitCommentEvent Event = "commit_comment"
|
||||||
CreateEvent Event = "create"
|
CreateEvent Event = "create"
|
||||||
DeleteEvent Event = "delete"
|
DeleteEvent Event = "delete"
|
||||||
DeploymentEvent Event = "deployment"
|
DeploymentEvent Event = "deployment"
|
||||||
DeploymentStatusEvent Event = "deployment_status"
|
DeploymentStatusEvent Event = "deployment_status"
|
||||||
ForkEvent Event = "fork"
|
ForkEvent Event = "fork"
|
||||||
GollumEvent Event = "gollum"
|
GollumEvent Event = "gollum"
|
||||||
InstallationEvent Event = "installation"
|
InstallationEvent Event = "installation"
|
||||||
InstallationRepositoriesEvent Event = "installation_repositories"
|
InstallationRepositoriesEvent Event = "installation_repositories"
|
||||||
IntegrationInstallationEvent Event = "integration_installation"
|
IntegrationInstallationEvent Event = "integration_installation"
|
||||||
IssueCommentEvent Event = "issue_comment"
|
IntegrationInstallationRepositoriesEvent Event = "integration_installation_repositories"
|
||||||
IssuesEvent Event = "issues"
|
IssueCommentEvent Event = "issue_comment"
|
||||||
LabelEvent Event = "label"
|
IssuesEvent Event = "issues"
|
||||||
MemberEvent Event = "member"
|
LabelEvent Event = "label"
|
||||||
MembershipEvent Event = "membership"
|
MemberEvent Event = "member"
|
||||||
MilestoneEvent Event = "milestone"
|
MembershipEvent Event = "membership"
|
||||||
OrganizationEvent Event = "organization"
|
MilestoneEvent Event = "milestone"
|
||||||
OrgBlockEvent Event = "org_block"
|
OrganizationEvent Event = "organization"
|
||||||
PageBuildEvent Event = "page_build"
|
OrgBlockEvent Event = "org_block"
|
||||||
PingEvent Event = "ping"
|
PageBuildEvent Event = "page_build"
|
||||||
ProjectCardEvent Event = "project_card"
|
PingEvent Event = "ping"
|
||||||
ProjectColumnEvent Event = "project_column"
|
ProjectCardEvent Event = "project_card"
|
||||||
ProjectEvent Event = "project"
|
ProjectColumnEvent Event = "project_column"
|
||||||
PublicEvent Event = "public"
|
ProjectEvent Event = "project"
|
||||||
PullRequestEvent Event = "pull_request"
|
PublicEvent Event = "public"
|
||||||
PullRequestReviewEvent Event = "pull_request_review"
|
PullRequestEvent Event = "pull_request"
|
||||||
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
|
PullRequestReviewEvent Event = "pull_request_review"
|
||||||
PushEvent Event = "push"
|
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
|
||||||
ReleaseEvent Event = "release"
|
PushEvent Event = "push"
|
||||||
RepositoryEvent Event = "repository"
|
ReleaseEvent Event = "release"
|
||||||
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
|
RepositoryEvent Event = "repository"
|
||||||
SecurityAdvisoryEvent Event = "security_advisory"
|
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
|
||||||
StatusEvent Event = "status"
|
SecurityAdvisoryEvent Event = "security_advisory"
|
||||||
TeamEvent Event = "team"
|
StatusEvent Event = "status"
|
||||||
TeamAddEvent Event = "team_add"
|
TeamEvent Event = "team"
|
||||||
WatchEvent Event = "watch"
|
TeamAddEvent Event = "team_add"
|
||||||
|
WatchEvent Event = "watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EventSubtype defines a GitHub Hook Event subtype
|
// EventSubtype defines a GitHub Hook Event subtype
|
||||||
@@ -206,7 +207,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
|
|||||||
var pl InstallationPayload
|
var pl InstallationPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
return pl, err
|
return pl, err
|
||||||
case InstallationRepositoriesEvent:
|
case InstallationRepositoriesEvent, IntegrationInstallationRepositoriesEvent:
|
||||||
var pl InstallationRepositoriesPayload
|
var pl InstallationRepositoriesPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
return pl, err
|
return pl, err
|
||||||
|
|||||||
@@ -253,6 +253,16 @@ func TestWebhooks(t *testing.T) {
|
|||||||
"X-Hub-Signature": []string{"sha1=bb2769f05f1a11af3a1edf8f9fac11bae7402a1e"},
|
"X-Hub-Signature": []string{"sha1=bb2769f05f1a11af3a1edf8f9fac11bae7402a1e"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "IntegrationInstallationRepositoriesEvent",
|
||||||
|
event: IntegrationInstallationRepositoriesEvent,
|
||||||
|
typ: InstallationRepositoriesPayload{},
|
||||||
|
filename: "../testdata/github/integration-installation-repositories.json",
|
||||||
|
headers: http.Header{
|
||||||
|
"X-Github-Event": []string{"integration_installation_repositories"},
|
||||||
|
"X-Hub-Signature": []string{"sha1=2f00a982574188342c2894eb9d1b1e93434687fb"},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "IssueCommentEvent",
|
name: "IssueCommentEvent",
|
||||||
event: IssueCommentEvent,
|
event: IssueCommentEvent,
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"action": "removed",
|
||||||
|
"installation": {
|
||||||
|
"id": 2,
|
||||||
|
"account": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"repository_selection": "selected",
|
||||||
|
"access_tokens_url": "https://api.github.com/installations/2/access_tokens",
|
||||||
|
"repositories_url": "https://api.github.com/installation/repositories",
|
||||||
|
"html_url": "https://github.com/settings/installations/2",
|
||||||
|
"app_id": 5725,
|
||||||
|
"target_id": 3880403,
|
||||||
|
"target_type": "User",
|
||||||
|
"permissions": {
|
||||||
|
"metadata": "read",
|
||||||
|
"contents": "read",
|
||||||
|
"issues": "write"
|
||||||
|
},
|
||||||
|
"events": [
|
||||||
|
"push",
|
||||||
|
"pull_request"
|
||||||
|
],
|
||||||
|
"created_at": 1525109898,
|
||||||
|
"updated_at": 1525109899,
|
||||||
|
"single_file_name": "config.yml"
|
||||||
|
},
|
||||||
|
"repository_selection": "selected",
|
||||||
|
"repositories_added": [],
|
||||||
|
"repositories_removed": [
|
||||||
|
{
|
||||||
|
"id": 1296269,
|
||||||
|
"name": "Hello-World",
|
||||||
|
"full_name": "octocat/Hello-World",
|
||||||
|
"private": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sender": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user