Skip to content

Commit

Permalink
Merge pull request #18 from tulir/patch-2
Browse files Browse the repository at this point in the history
[GitLab] Add support for confidential issues
  • Loading branch information
deankarn authored Oct 2, 2017
2 parents 4964805 + 13e6611 commit 5462959
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 14 additions & 8 deletions gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ type Event string

// GitLab hook types
const (
PushEvents Event = "Push Hook"
TagEvents Event = "Tag Push Hook"
IssuesEvents Event = "Issue Hook"
CommentEvents Event = "Note Hook"
MergeRequestEvents Event = "Merge Request Hook"
WikiPageEvents Event = "Wiki Page Hook"
PipelineEvents Event = "Pipeline Hook"
BuildEvents Event = "Build Hook"
PushEvents Event = "Push Hook"
TagEvents Event = "Tag Push Hook"
IssuesEvents Event = "Issue Hook"
ConfidentialIssuesEvents Event = "Confidential Issue Hook"
CommentEvents Event = "Note Hook"
MergeRequestEvents Event = "Merge Request Hook"
WikiPageEvents Event = "Wiki Page Hook"
PipelineEvents Event = "Pipeline Hook"
BuildEvents Event = "Build Hook"
)

// New creates and returns a WebHook instance denoted by the Provider type
Expand Down Expand Up @@ -112,6 +113,11 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) {
json.Unmarshal([]byte(payload), &te)
hook.runProcessPayloadFunc(fn, te, hd)

case ConfidentialIssuesEvents:
var cie ConfidentialIssueEventPayload
json.Unmarshal([]byte(payload), &cie)
hook.runProcessPayloadFunc(fn, cie, hd)

case IssuesEvents:
var ie IssueEventPayload
json.Unmarshal([]byte(payload), &ie)
Expand Down
7 changes: 7 additions & 0 deletions gitlab/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ type IssueEventPayload struct {
Assignee Assignee `json:"assignee"`
}

// ConfidentialIssueEventPayload contains the information for GitLab's confidential issue event
type ConfidentialIssueEventPayload struct {
// The data for confidential issues is currently the same as normal issues,
// so we can just embed the normal issue payload type here.
IssueEventPayload
}

// MergeRequestEventPayload contains the information for GitLab's merge request event
type MergeRequestEventPayload struct {
ObjectKind string `json:"object_kind"`
Expand Down

0 comments on commit 5462959

Please sign in to comment.