handle system events
This commit is contained in:
parent
a0493bd805
commit
e3fc3f9fc7
|
@ -1,6 +1,7 @@
|
||||||
package gitlab
|
package gitlab
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -89,6 +90,27 @@ func init() {
|
||||||
err = libHTTP.Read(r, &pl)
|
err = libHTTP.Read(r, &pl)
|
||||||
msg = pl.String()
|
msg = pl.String()
|
||||||
|
|
||||||
|
case SystemEvents:
|
||||||
|
var data map[string]interface{}
|
||||||
|
err = json.NewDecoder(r.Body).Decode(data)
|
||||||
|
if err != nil {
|
||||||
|
err = nil
|
||||||
|
msg = fmt.Sprintf("unable to decode gitlab system event")
|
||||||
|
} else if event, ok := data["event_name"]; ok {
|
||||||
|
switch event {
|
||||||
|
case "push":
|
||||||
|
var pl PushEventPayload
|
||||||
|
err = libHTTP.Read(r, &pl)
|
||||||
|
msg = pl.String()
|
||||||
|
default:
|
||||||
|
err = nil
|
||||||
|
msg = fmt.Sprintf("unknown gitlab system event '%s' received", event)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = nil
|
||||||
|
msg = fmt.Sprintf("unable to get event_name of gitlab system event")
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = nil
|
err = nil
|
||||||
msg = fmt.Sprintf("unknown gitlab event '%s' received", gitLabEvent)
|
msg = fmt.Sprintf("unknown gitlab event '%s' received", gitLabEvent)
|
||||||
|
|
|
@ -19,6 +19,7 @@ const (
|
||||||
WikiPageEvents Event = "Wiki Page Hook"
|
WikiPageEvents Event = "Wiki Page Hook"
|
||||||
PipelineEvents Event = "Pipeline Hook"
|
PipelineEvents Event = "Pipeline Hook"
|
||||||
BuildEvents Event = "Build Hook"
|
BuildEvents Event = "Build Hook"
|
||||||
|
SystemEvents Event = "System Hook"
|
||||||
)
|
)
|
||||||
|
|
||||||
type customTime struct {
|
type customTime struct {
|
||||||
|
|
Loading…
Reference in New Issue