Skip to content

Commit

Permalink
rm workaround for gitlab webhook parsing (#601)
Browse files Browse the repository at this point in the history
upstream got merged: xanzy/go-gitlab#1282
possible because of #599
  • Loading branch information
6543 authored Dec 12, 2021
1 parent 70fcc17 commit 0e89923
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions server/remote/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package gitlab
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net"
Expand Down Expand Up @@ -467,26 +466,7 @@ func (g *Gitlab) Hook(req *http.Request) (*model.Repo, *model.Build, error) {
return nil, nil, err
}

eventType := gitlab.WebhookEventType(req)
// TODO: Fix Upstream: We get `Service Hook` - which the library do not understand
if eventType == "Service Hook" {
e := struct {
ObjectKind string `json:"object_kind"`
}{}
if err := json.Unmarshal(payload, &e); err != nil {
return nil, nil, err
}
switch e.ObjectKind {
case "push":
eventType = gitlab.EventTypePush
case "tag_push":
eventType = gitlab.EventTypeTagPush
case "merge_request":
eventType = gitlab.EventTypeMergeRequest
}
}

parsed, err := gitlab.ParseWebhook(eventType, payload)
parsed, err := gitlab.ParseWebhook(gitlab.WebhookEventType(req), payload)
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 0e89923

Please sign in to comment.