Skip to content

Commit 5ed22cd

Browse files
author
Dean Karn
committed
Initial GitHub Webhook revamp
1 parent 2e471dc commit 5ed22cd

File tree

9 files changed

+6710
-966
lines changed

9 files changed

+6710
-966
lines changed

bitbucket/bitbucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io/ioutil"
66
"net/http"
77

8-
"gopkg.in/go-playground/webhooks.v2"
8+
"gopkg.in/go-playground/webhooks.v3"
99
)
1010

1111
// Webhook instance contains all methods needed to process events

bitbucket/bitbucket_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"time"
1010

1111
. "gopkg.in/go-playground/assert.v1"
12-
"gopkg.in/go-playground/webhooks.v2"
12+
"gopkg.in/go-playground/webhooks.v3"
1313
)
1414

1515
// NOTES:

examples/multiple-handlers/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"strconv"
66

7-
"gopkg.in/go-playground/webhooks.v2"
8-
"gopkg.in/go-playground/webhooks.v2/github"
7+
"gopkg.in/go-playground/webhooks.v3"
8+
"gopkg.in/go-playground/webhooks.v3/github"
99
)
1010

1111
const (

examples/single-handler/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"strconv"
66

7-
"gopkg.in/go-playground/webhooks.v2"
8-
"gopkg.in/go-playground/webhooks.v2/github"
7+
"gopkg.in/go-playground/webhooks.v3"
8+
"gopkg.in/go-playground/webhooks.v3/github"
99
)
1010

1111
const (

github/github.go

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"io/ioutil"
99
"net/http"
1010

11-
"gopkg.in/go-playground/webhooks.v2"
11+
"gopkg.in/go-playground/webhooks.v3"
1212
)
1313

1414
// Webhook instance contains all methods needed to process events
@@ -37,16 +37,25 @@ const (
3737
GollumEvent Event = "gollum"
3838
IssueCommentEvent Event = "issue_comment"
3939
IssuesEvent Event = "issues"
40+
LabelEvent Event = "label"
4041
MemberEvent Event = "member"
4142
MembershipEvent Event = "membership"
43+
MilestoneEvent Event = "milestone"
44+
OrganizationEvent Event = "organization"
45+
OrgBlockEvent Event = "org_block"
4246
PageBuildEvent Event = "page_build"
47+
ProjectCardEvent Event = "project_card"
48+
ProjectColumnEvent Event = "project_column"
49+
ProjectEvent Event = "project"
4350
PublicEvent Event = "public"
44-
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
4551
PullRequestEvent Event = "pull_request"
52+
PullRequestReviewEvent Event = "pull_request_review"
53+
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
4654
PushEvent Event = "push"
47-
RepositoryEvent Event = "repository"
4855
ReleaseEvent Event = "release"
56+
RepositoryEvent Event = "repository"
4957
StatusEvent Event = "status"
58+
TeamEvent Event = "team"
5059
TeamAddEvent Event = "team_add"
5160
WatchEvent Event = "watch"
5261
)
@@ -169,6 +178,10 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) {
169178
var i IssuesPayload
170179
json.Unmarshal([]byte(payload), &i)
171180
hook.runProcessPayloadFunc(fn, i, hd)
181+
case LabelEvent:
182+
var l LabelPayload
183+
json.Unmarshal([]byte(payload), &l)
184+
hook.runProcessPayloadFunc(fn, l, hd)
172185
case MemberEvent:
173186
var m MemberPayload
174187
json.Unmarshal([]byte(payload), &m)
@@ -177,38 +190,70 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) {
177190
var m MembershipPayload
178191
json.Unmarshal([]byte(payload), &m)
179192
hook.runProcessPayloadFunc(fn, m, hd)
193+
case MilestoneEvent:
194+
var m MilestonePayload
195+
json.Unmarshal([]byte(payload), &m)
196+
hook.runProcessPayloadFunc(fn, m, hd)
197+
case OrganizationEvent:
198+
var o OrganizationPayload
199+
json.Unmarshal([]byte(payload), &o)
200+
hook.runProcessPayloadFunc(fn, o, hd)
201+
case OrgBlockEvent:
202+
var o OrgBlockPayload
203+
json.Unmarshal([]byte(payload), &o)
204+
hook.runProcessPayloadFunc(fn, o, hd)
180205
case PageBuildEvent:
181206
var p PageBuildPayload
182207
json.Unmarshal([]byte(payload), &p)
183208
hook.runProcessPayloadFunc(fn, p, hd)
184-
case PublicEvent:
185-
var p PublicPayload
209+
case ProjectCardEvent:
210+
var p ProjectCardPayload
186211
json.Unmarshal([]byte(payload), &p)
187212
hook.runProcessPayloadFunc(fn, p, hd)
188-
case PullRequestReviewCommentEvent:
189-
var p PullRequestReviewCommentPayload
213+
case ProjectColumnEvent:
214+
var p ProjectColumnPayload
215+
json.Unmarshal([]byte(payload), &p)
216+
hook.runProcessPayloadFunc(fn, p, hd)
217+
case ProjectEvent:
218+
var p ProjectPayload
219+
json.Unmarshal([]byte(payload), &p)
220+
hook.runProcessPayloadFunc(fn, p, hd)
221+
case PublicEvent:
222+
var p PublicPayload
190223
json.Unmarshal([]byte(payload), &p)
191224
hook.runProcessPayloadFunc(fn, p, hd)
192225
case PullRequestEvent:
193226
var p PullRequestPayload
194227
json.Unmarshal([]byte(payload), &p)
195228
hook.runProcessPayloadFunc(fn, p, hd)
229+
case PullRequestReviewEvent:
230+
var p PullRequestReviewPayload
231+
json.Unmarshal([]byte(payload), &p)
232+
hook.runProcessPayloadFunc(fn, p, hd)
233+
case PullRequestReviewCommentEvent:
234+
var p PullRequestReviewCommentPayload
235+
json.Unmarshal([]byte(payload), &p)
236+
hook.runProcessPayloadFunc(fn, p, hd)
196237
case PushEvent:
197238
var p PushPayload
198239
json.Unmarshal([]byte(payload), &p)
199240
hook.runProcessPayloadFunc(fn, p, hd)
200-
case RepositoryEvent:
201-
var r RepositoryPayload
202-
json.Unmarshal([]byte(payload), &r)
203-
hook.runProcessPayloadFunc(fn, r, hd)
204241
case ReleaseEvent:
205242
var r ReleasePayload
206243
json.Unmarshal([]byte(payload), &r)
207244
hook.runProcessPayloadFunc(fn, r, hd)
245+
case RepositoryEvent:
246+
var r RepositoryPayload
247+
json.Unmarshal([]byte(payload), &r)
248+
hook.runProcessPayloadFunc(fn, r, hd)
208249
case StatusEvent:
209250
var s StatusPayload
210251
json.Unmarshal([]byte(payload), &s)
211252
hook.runProcessPayloadFunc(fn, s, hd)
253+
case TeamEvent:
254+
var t TeamPayload
255+
json.Unmarshal([]byte(payload), &t)
256+
hook.runProcessPayloadFunc(fn, t, hd)
212257
case TeamAddEvent:
213258
var t TeamAddPayload
214259
json.Unmarshal([]byte(payload), &t)

0 commit comments

Comments
 (0)