Skip to content

Commit

Permalink
Respond 200 when receiving a ping event. (influxdata#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz authored and Vladislav Mugultyanov (Lazada Group) committed May 30, 2017
1 parent e497c4a commit 233e92c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/inputs/webhooks/github/github_webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ func (gh *GithubWebhook) eventHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
return
}

p := e.NewMetric()
gh.acc.AddFields("github_webhooks", p.Fields(), p.Tags(), p.Time())
if e != nil {
p := e.NewMetric()
gh.acc.AddFields("github_webhooks", p.Fields(), p.Tags(), p.Time())
}

w.WriteHeader(http.StatusOK)
}
Expand Down Expand Up @@ -84,6 +85,8 @@ func NewEvent(data []byte, name string) (Event, error) {
return generateEvent(data, &MembershipEvent{})
case "page_build":
return generateEvent(data, &PageBuildEvent{})
case "ping":
return nil, nil
case "public":
return generateEvent(data, &PublicEvent{})
case "pull_request":
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/webhooks/github/github_webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func TestCommitCommentEvent(t *testing.T) {
GithubWebhookRequest("commit_comment", CommitCommentEventJSON(), t)
}

func TestPingEvent(t *testing.T) {
GithubWebhookRequest("ping", "", t)
}

func TestDeleteEvent(t *testing.T) {
GithubWebhookRequest("delete", DeleteEventJSON(), t)
}
Expand Down

0 comments on commit 233e92c

Please sign in to comment.