Skip to content

Commit

Permalink
Merge pull request #11031 from vanloswang/master
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Sep 26, 2016
2 parents 468414b + ca6be6d commit 2b02ee4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions pkg/build/webhook/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
ErrNoGitHubEvent = errors.New("missing X-GitHub-Event or X-Gogs-Event")
ErrNoGitHubEvent = errors.New("missing X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event")
)

// WebHook used for processing github webhook requests.
Expand Down Expand Up @@ -57,8 +57,8 @@ func (p *WebHook) Extract(buildCfg *api.BuildConfig, secret, path string, req *h
return revision, envvars, proceed, err
}
method := getEvent(req.Header)
if method != "ping" && method != "push" {
return revision, envvars, proceed, fmt.Errorf("Unknown X-GitHub-Event or X-Gogs-Event %s", method)
if method != "ping" && method != "push" && method != "Push Hook" {
return revision, envvars, proceed, fmt.Errorf("Unknown X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event %s", method)
}
if method == "ping" {
return revision, envvars, proceed, err
Expand Down Expand Up @@ -110,5 +110,8 @@ func getEvent(header http.Header) string {
if len(event) == 0 {
event = header.Get("X-Gogs-Event")
}
if len(event) == 0 {
event = header.Get("X-Gitlab-Event")
}
return event
}
8 changes: 4 additions & 4 deletions pkg/build/webhook/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestMissingEvent(t *testing.T) {
plugin := New()
revision, _, proceed, err := plugin.Extract(buildConfig, "secret100", "", req)

if err == nil || !strings.Contains(err.Error(), "missing X-GitHub-Event or X-Gogs-Event") {
t.Errorf("Expected missing X-GitHub-Event or X-Gogs-Event, got %v", err)
if err == nil || !strings.Contains(err.Error(), "missing X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event") {
t.Errorf("Expected missing X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event, got %v", err)
}
if proceed {
t.Error("Expected 'proceed' return value to be 'false'")
Expand All @@ -165,8 +165,8 @@ func TestWrongGitHubEvent(t *testing.T) {
plugin := New()
revision, _, proceed, err := plugin.Extract(buildConfig, "secret100", "", req)

if err == nil || !strings.Contains(err.Error(), "Unknown X-GitHub-Event or X-Gogs-Event") {
t.Errorf("Expected missing Unknown X-GitHub-Event or X-Gogs-Event, got %v", err)
if err == nil || !strings.Contains(err.Error(), "Unknown X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event") {
t.Errorf("Expected missing Unknown X-GitHub-Event, X-Gogs-Event or X-Gitlab-Event, got %v", err)
}
if proceed {
t.Error("Expected 'proceed' return value to be 'false'")
Expand Down

0 comments on commit 2b02ee4

Please sign in to comment.