Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1051fd871 | |||
| ac198c9e6a | |||
| e157e8e469 | |||
| b2ca22db96 | |||
| dee47c0482 | |||
| bba5196bce | |||
| 80aa7fa2fe | |||
| 88515706e6 | |||
| f1f5db7261 | |||
| a92dd933ba | |||
| 26ca2ef893 | |||
| 4fb25871a6 | |||
| 22a6a67d07 | |||
| d7570ff094 | |||
| 2dbe987740 | |||
| b3a5a8edf7 | |||
| dfc330f6eb | |||
| cdc59eb3ef | |||
| a39ebc145a | |||
| 24279ccb4b | |||
| 4708dcb9f1 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.10.3
|
- 1.11.2
|
||||||
- tip
|
- tip
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
@@ -29,6 +29,6 @@ script:
|
|||||||
- make test
|
- make test
|
||||||
|
|
||||||
after_success: |
|
after_success: |
|
||||||
[ $TRAVIS_GO_VERSION = 1.10.3 ] &&
|
[ $TRAVIS_GO_VERSION = 1.11.2 ] &&
|
||||||
overalls -project="github.com/go-playground/webhooks" -covermode=count -ignore=.git,_examples,testdata -debug &&
|
overalls -project="github.com/go-playground/webhooks" -covermode=count -ignore=.git,_examples,testdata -debug &&
|
||||||
goveralls -coverprofile=overalls.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
|
goveralls -coverprofile=overalls.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Library webhooks
|
Library webhooks
|
||||||
================
|
================
|
||||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">
|
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">
|
||||||
[](https://travis-ci.org/go-playground/webhooks)
|
[](https://travis-ci.org/go-playground/webhooks)
|
||||||
[](https://coveralls.io/github/go-playground/webhooks?branch=v5)
|
[](https://coveralls.io/github/go-playground/webhooks?branch=v5)
|
||||||
[](https://goreportcard.com/report/go-playground/webhooks)
|
[](https://goreportcard.com/report/go-playground/webhooks)
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
// this package recieves the Docker Hub Automated Build webhook
|
||||||
|
// https://docs.docker.com/docker-hub/webhooks/
|
||||||
|
// NOT the Docker Trusted Registry webhook
|
||||||
|
// https://docs.docker.com/ee/dtr/user/create-and-manage-webhooks/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// parse errors
|
||||||
|
var (
|
||||||
|
ErrInvalidHTTPMethod = errors.New("invalid HTTP Method")
|
||||||
|
ErrParsingPayload = errors.New("error parsing payload")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Event defines a Docker hook event type
|
||||||
|
type Event string
|
||||||
|
|
||||||
|
// Docker hook types (only one for now)
|
||||||
|
const (
|
||||||
|
BuildEvent Event = "build"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BuildPayload a docker hub build notice
|
||||||
|
// https://docs.docker.com/docker-hub/webhooks/
|
||||||
|
type BuildPayload struct {
|
||||||
|
CallbackURL string `json:"callback_url"`
|
||||||
|
PushData struct {
|
||||||
|
Images []string `json:"images"`
|
||||||
|
PushedAt float32 `json:"pushed_at"`
|
||||||
|
Pusher string `json:"pusher"`
|
||||||
|
Tag string `json:"tag"`
|
||||||
|
} `json:"push_data"`
|
||||||
|
Repository struct {
|
||||||
|
CommentCount int `json:"comment_count"`
|
||||||
|
DateCreated float32 `json:"date_created"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Dockerfile string `json:"dockerfile"`
|
||||||
|
FullDescription string `json:"full_description"`
|
||||||
|
IsOfficial bool `json:"is_official"`
|
||||||
|
IsPrivate bool `json:"is_private"`
|
||||||
|
IsTrusted bool `json:"is_trusted"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Owner string `json:"owner"`
|
||||||
|
RepoName string `json:"repo_name"`
|
||||||
|
RepoURL string `json:"repo_url"`
|
||||||
|
StarCount int `json:"star_count"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
} `json:"repository"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Webhook instance contains all methods needed to process events
|
||||||
|
type Webhook struct {
|
||||||
|
secret string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates and returns a WebHook instance
|
||||||
|
func New() (*Webhook, error) {
|
||||||
|
hook := new(Webhook)
|
||||||
|
return hook, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse verifies and parses the events specified and returns the payload object or an error
|
||||||
|
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
|
||||||
|
defer func() {
|
||||||
|
_, _ = io.Copy(ioutil.Discard, r.Body)
|
||||||
|
_ = r.Body.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
|
if r.Method != http.MethodPost {
|
||||||
|
return nil, ErrInvalidHTTPMethod
|
||||||
|
}
|
||||||
|
|
||||||
|
payload, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err != nil || len(payload) == 0 {
|
||||||
|
return nil, ErrParsingPayload
|
||||||
|
}
|
||||||
|
|
||||||
|
var pl BuildPayload
|
||||||
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ErrParsingPayload
|
||||||
|
}
|
||||||
|
return pl, err
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NOTES:
|
||||||
|
// - Run "go test" to run tests
|
||||||
|
// - Run "gocov test | gocov report" to report on test converage by file
|
||||||
|
// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called
|
||||||
|
//
|
||||||
|
// or
|
||||||
|
//
|
||||||
|
// -- may be a good idea to change to output path to somewherelike /tmp
|
||||||
|
// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html
|
||||||
|
//
|
||||||
|
|
||||||
|
const (
|
||||||
|
path = "/webhooks"
|
||||||
|
)
|
||||||
|
|
||||||
|
var hook *Webhook
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
|
||||||
|
// setup
|
||||||
|
var err error
|
||||||
|
hook, err = New()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
os.Exit(m.Run())
|
||||||
|
// teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
func newServer(handler http.HandlerFunc) *httptest.Server {
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc(path, handler)
|
||||||
|
return httptest.NewServer(mux)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWebhooks(t *testing.T) {
|
||||||
|
assert := require.New(t)
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
event Event
|
||||||
|
typ interface{}
|
||||||
|
filename string
|
||||||
|
headers http.Header
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "BuildEvent",
|
||||||
|
event: BuildEvent,
|
||||||
|
typ: BuildPayload{},
|
||||||
|
filename: "../testdata/docker/docker_hub_build_notice.json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
tc := tt
|
||||||
|
client := &http.Client{}
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
payload, err := os.Open(tc.filename)
|
||||||
|
assert.NoError(err)
|
||||||
|
defer func() {
|
||||||
|
_ = payload.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
|
var parseError error
|
||||||
|
var results interface{}
|
||||||
|
server := newServer(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
results, parseError = hook.Parse(r, tc.event)
|
||||||
|
})
|
||||||
|
defer server.Close()
|
||||||
|
req, err := http.NewRequest(http.MethodPost, server.URL+path, payload)
|
||||||
|
assert.NoError(err)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
|
assert.NoError(parseError)
|
||||||
|
assert.Equal(reflect.TypeOf(tc.typ), reflect.TypeOf(results))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@ const (
|
|||||||
ForkEvent Event = "fork"
|
ForkEvent Event = "fork"
|
||||||
GollumEvent Event = "gollum"
|
GollumEvent Event = "gollum"
|
||||||
InstallationEvent Event = "installation"
|
InstallationEvent Event = "installation"
|
||||||
|
InstallationRepositoriesEvent Event = "installation_repositories"
|
||||||
IntegrationInstallationEvent Event = "integration_installation"
|
IntegrationInstallationEvent Event = "integration_installation"
|
||||||
IssueCommentEvent Event = "issue_comment"
|
IssueCommentEvent Event = "issue_comment"
|
||||||
IssuesEvent Event = "issues"
|
IssuesEvent Event = "issues"
|
||||||
@@ -193,6 +194,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
|
|||||||
var pl InstallationPayload
|
var pl InstallationPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
return pl, err
|
return pl, err
|
||||||
|
case InstallationRepositoriesEvent:
|
||||||
|
var pl InstallationRepositoriesPayload
|
||||||
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
|
return pl, err
|
||||||
case IssueCommentEvent:
|
case IssueCommentEvent:
|
||||||
var pl IssueCommentPayload
|
var pl IssueCommentPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
|
|||||||
@@ -213,6 +213,16 @@ func TestWebhooks(t *testing.T) {
|
|||||||
"X-Hub-Signature": []string{"sha1=2058cf6cc28570710afbc638e669f5c67305a2db"},
|
"X-Hub-Signature": []string{"sha1=2058cf6cc28570710afbc638e669f5c67305a2db"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "InstallationRepositoriesEvent",
|
||||||
|
event: InstallationRepositoriesEvent,
|
||||||
|
typ: InstallationRepositoriesPayload{},
|
||||||
|
filename: "../testdata/github/installation-repositories.json",
|
||||||
|
headers: http.Header{
|
||||||
|
"X-Github-Event": []string{"installation_repositories"},
|
||||||
|
"X-Hub-Signature": []string{"sha1=c587fbd9dd169db8ae592b3bcc80b08e2e6f4f45"},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "IntegrationInstallationEvent",
|
name: "IntegrationInstallationEvent",
|
||||||
event: IntegrationInstallationEvent,
|
event: IntegrationInstallationEvent,
|
||||||
|
|||||||
+141
-44
@@ -1073,6 +1073,86 @@ type InstallationPayload struct {
|
|||||||
} `json:"sender"`
|
} `json:"sender"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InstallationRepositoriesPayload contains the information for GitHub's installation_repositories hook events
|
||||||
|
type InstallationRepositoriesPayload struct {
|
||||||
|
Action string `json:"action"`
|
||||||
|
Installation struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Account struct {
|
||||||
|
Login string `json:"login"`
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
GravatarID string `json:"gravatar_id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
|
FollowersURL string `json:"followers_url"`
|
||||||
|
FollowingURL string `json:"following_url"`
|
||||||
|
GistsURL string `json:"gists_url"`
|
||||||
|
StarredURL string `json:"starred_url"`
|
||||||
|
SubscriptionsURL string `json:"subscriptions_url"`
|
||||||
|
OrganizationsURL string `json:"organizations_url"`
|
||||||
|
ReposURL string `json:"repos_url"`
|
||||||
|
EventsURL string `json:"events_url"`
|
||||||
|
ReceivedEventsURL string `json:"received_events_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SiteAdmin bool `json:"site_admin"`
|
||||||
|
} `json:"account"`
|
||||||
|
RepositorySelection string `json:"repository_selection"`
|
||||||
|
AccessTokensURL string `json:"access_tokens_url"`
|
||||||
|
RepositoriesURL string `json:"repositories_url"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
|
AppID int `json:"app_id"`
|
||||||
|
TargetID int `json:"target_id"`
|
||||||
|
TargetType string `json:"target_type"`
|
||||||
|
Permissions struct {
|
||||||
|
Issues string `json:"issues"`
|
||||||
|
Metadata string `json:"metadata"`
|
||||||
|
PullRequests string `json:"pull_requests"`
|
||||||
|
RepositoryProjects string `json:"repository_projects"`
|
||||||
|
VulnerabilityAlerts string `json:"vulnerability_alerts"`
|
||||||
|
Statuses string `json:"statuses"`
|
||||||
|
Administration string `json:"administration"`
|
||||||
|
Deployments string `json:"deployments"`
|
||||||
|
Contents string `json:"contents"`
|
||||||
|
} `json:"permissions"`
|
||||||
|
Events []string `json:"events"`
|
||||||
|
CreatedAt int64 `json:"created_at"`
|
||||||
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
|
SingleFileName *string `json:"single_file_name"`
|
||||||
|
} `json:"installation"`
|
||||||
|
RepositoriesAdded []struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
FullName string `json:"full_name"`
|
||||||
|
Private bool `json:"private"`
|
||||||
|
} `json:"repositories_added"`
|
||||||
|
RepositoriesRemoved []struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
FullName string `json:"full_name"`
|
||||||
|
Private bool `json:"private"`
|
||||||
|
} `json:"repositories_removed"`
|
||||||
|
Sender struct {
|
||||||
|
Login string `json:"login"`
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
GravatarID string `json:"gravatar_id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
|
FollowersURL string `json:"followers_url"`
|
||||||
|
FollowingURL string `json:"following_url"`
|
||||||
|
GistsURL string `json:"gists_url"`
|
||||||
|
StarredURL string `json:"starred_url"`
|
||||||
|
SubscriptionsURL string `json:"subscriptions_url"`
|
||||||
|
OrganizationsURL string `json:"organizations_url"`
|
||||||
|
ReposURL string `json:"repos_url"`
|
||||||
|
EventsURL string `json:"events_url"`
|
||||||
|
ReceivedEventsURL string `json:"received_events_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SiteAdmin bool `json:"site_admin"`
|
||||||
|
} `json:"sender"`
|
||||||
|
}
|
||||||
|
|
||||||
// IssueCommentPayload contains the information for GitHub's issue_comment hook event
|
// IssueCommentPayload contains the information for GitHub's issue_comment hook event
|
||||||
type IssueCommentPayload struct {
|
type IssueCommentPayload struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
@@ -1109,15 +1189,16 @@ type IssueCommentPayload struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
} `json:"labels"`
|
} `json:"labels"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
Locked bool `json:"locked"`
|
Locked bool `json:"locked"`
|
||||||
Assignee *Assignee `json:"assignee"`
|
Assignee *Assignee `json:"assignee"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Assignees []*Assignee `json:"assignees"`
|
||||||
Comments int64 `json:"comments"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
Comments int64 `json:"comments"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
ClosedAt *time.Time `json:"closed_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
Body string `json:"body"`
|
ClosedAt *time.Time `json:"closed_at"`
|
||||||
|
Body string `json:"body"`
|
||||||
} `json:"issue"`
|
} `json:"issue"`
|
||||||
Comment struct {
|
Comment struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
@@ -1294,15 +1375,16 @@ type IssuesPayload struct {
|
|||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Default bool `json:"default"`
|
Default bool `json:"default"`
|
||||||
} `json:"labels"`
|
} `json:"labels"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
Locked bool `json:"locked"`
|
Locked bool `json:"locked"`
|
||||||
Assignee *Assignee `json:"assignee"`
|
Assignee *Assignee `json:"assignee"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Assignees []*Assignee `json:"assignees"`
|
||||||
Comments int64 `json:"comments"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
Comments int64 `json:"comments"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
ClosedAt *time.Time `json:"closed_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
Body string `json:"body"`
|
ClosedAt *time.Time `json:"closed_at"`
|
||||||
|
Body string `json:"body"`
|
||||||
} `json:"issue"`
|
} `json:"issue"`
|
||||||
Repository struct {
|
Repository struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
@@ -1410,6 +1492,8 @@ type IssuesPayload struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
SiteAdmin bool `json:"site_admin"`
|
SiteAdmin bool `json:"site_admin"`
|
||||||
} `json:"sender"`
|
} `json:"sender"`
|
||||||
|
Assignee *Assignee `json:"assignee"`
|
||||||
|
Label *Label `json:"label"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LabelPayload contains the information for GitHub's label hook event
|
// LabelPayload contains the information for GitHub's label hook event
|
||||||
@@ -2757,19 +2841,20 @@ type PullRequestPayload struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
SiteAdmin bool `json:"site_admin"`
|
SiteAdmin bool `json:"site_admin"`
|
||||||
} `json:"user"`
|
} `json:"user"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
ClosedAt *time.Time `json:"closed_at"`
|
ClosedAt *time.Time `json:"closed_at"`
|
||||||
MergedAt *time.Time `json:"merged_at"`
|
MergedAt *time.Time `json:"merged_at"`
|
||||||
MergeCommitSha *string `json:"merge_commit_sha"`
|
MergeCommitSha *string `json:"merge_commit_sha"`
|
||||||
Assignee *Assignee `json:"assignee"`
|
Assignee *Assignee `json:"assignee"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Assignees []*Assignee `json:"assignees"`
|
||||||
CommitsURL string `json:"commits_url"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
ReviewCommentsURL string `json:"review_comments_url"`
|
CommitsURL string `json:"commits_url"`
|
||||||
ReviewCommentURL string `json:"review_comment_url"`
|
ReviewCommentsURL string `json:"review_comments_url"`
|
||||||
CommentsURL string `json:"comments_url"`
|
ReviewCommentURL string `json:"review_comment_url"`
|
||||||
StatusesURL string `json:"statuses_url"`
|
CommentsURL string `json:"comments_url"`
|
||||||
|
StatusesURL string `json:"statuses_url"`
|
||||||
RequestedReviewers []struct {
|
RequestedReviewers []struct {
|
||||||
Login string `json:"login"`
|
Login string `json:"login"`
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
@@ -3168,6 +3253,7 @@ type PullRequestPayload struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
SiteAdmin bool `json:"site_admin"`
|
SiteAdmin bool `json:"site_admin"`
|
||||||
} `json:"sender"`
|
} `json:"sender"`
|
||||||
|
Assignee *Assignee `json:"assignee"`
|
||||||
Installation struct {
|
Installation struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
} `json:"installation"`
|
} `json:"installation"`
|
||||||
@@ -3663,6 +3749,7 @@ type PullRequestReviewCommentPayload struct {
|
|||||||
Href string `json:"href"`
|
Href string `json:"href"`
|
||||||
} `json:"pull_request"`
|
} `json:"pull_request"`
|
||||||
} `json:"_links"`
|
} `json:"_links"`
|
||||||
|
InReplyToID int64 `json:"in_reply_to_id"`
|
||||||
} `json:"comment"`
|
} `json:"comment"`
|
||||||
PullRequest struct {
|
PullRequest struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
@@ -3694,19 +3781,20 @@ type PullRequestReviewCommentPayload struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
SiteAdmin bool `json:"site_admin"`
|
SiteAdmin bool `json:"site_admin"`
|
||||||
} `json:"user"`
|
} `json:"user"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
ClosedAt *time.Time `json:"closed_at"`
|
ClosedAt *time.Time `json:"closed_at"`
|
||||||
MergedAt *time.Time `json:"merged_at"`
|
MergedAt *time.Time `json:"merged_at"`
|
||||||
MergeCommitSha string `json:"merge_commit_sha"`
|
MergeCommitSha string `json:"merge_commit_sha"`
|
||||||
Assignee *Assignee `json:"assignee"`
|
Assignee *Assignee `json:"assignee"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Assignees []*Assignee `json:"assignees"`
|
||||||
CommitsURL string `json:"commits_url"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
ReviewCommentsURL string `json:"review_comments_url"`
|
CommitsURL string `json:"commits_url"`
|
||||||
ReviewCommentURL string `json:"review_comment_url"`
|
ReviewCommentsURL string `json:"review_comments_url"`
|
||||||
CommentsURL string `json:"comments_url"`
|
ReviewCommentURL string `json:"review_comment_url"`
|
||||||
StatusesURL string `json:"statuses_url"`
|
CommentsURL string `json:"comments_url"`
|
||||||
|
StatusesURL string `json:"statuses_url"`
|
||||||
Head struct {
|
Head struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Ref string `json:"ref"`
|
Ref string `json:"ref"`
|
||||||
@@ -5101,3 +5189,12 @@ type Parent struct {
|
|||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Sha string `json:"sha"`
|
Sha string `json:"sha"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Label contains Issue's Label information
|
||||||
|
type Label struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
Default bool `json:"default"`
|
||||||
|
}
|
||||||
|
|||||||
+9
-1
@@ -177,10 +177,18 @@ type Build struct {
|
|||||||
When string `json:"when"`
|
When string `json:"when"`
|
||||||
Manual bool `json:"manual"`
|
Manual bool `json:"manual"`
|
||||||
User User `json:"user"`
|
User User `json:"user"`
|
||||||
Runner string `json:"runner"`
|
Runner Runner `json:"runner"`
|
||||||
ArtifactsFile ArtifactsFile `json:"artifactsfile"`
|
ArtifactsFile ArtifactsFile `json:"artifactsfile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Runner represents a runner agent
|
||||||
|
type Runner struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
IsShared bool `json:"is_shared"`
|
||||||
|
}
|
||||||
|
|
||||||
// ArtifactsFile contains all of the GitLab artifact information
|
// ArtifactsFile contains all of the GitLab artifact information
|
||||||
type ArtifactsFile struct {
|
type ArtifactsFile struct {
|
||||||
Filename string `json:"filename"`
|
Filename string `json:"filename"`
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"callback_url": "https://registry.hub.docker.com/u/svendowideit/testhook/hook/2141b5bi5i5b02bec211i4eeih0242eg11000a/",
|
||||||
|
"push_data": {
|
||||||
|
"images": [
|
||||||
|
"27d47432a69bca5f2700e4dff7de0388ed65f9d3fb1ec645e2bc24c223dc1cc3",
|
||||||
|
"51a9c7c1f8bb2fa19bcd09789a34e63f35abb80044bc10196e304f6634cc582c",
|
||||||
|
"..."
|
||||||
|
],
|
||||||
|
"pushed_at": 1.417566161e+09,
|
||||||
|
"pusher": "trustedbuilder",
|
||||||
|
"tag": "latest"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"comment_count": 0,
|
||||||
|
"date_created": 1.417494799e+09,
|
||||||
|
"description": "",
|
||||||
|
"dockerfile": "#\n# BUILD\u0009\u0009docker build -t svendowideit/apt-cacher .\n# RUN\u0009\u0009docker run -d -p 3142:3142 -name apt-cacher-run apt-cacher\n#\n# and then you can run containers with:\n# \u0009\u0009docker run -t -i -rm -e http_proxy http://192.168.1.2:3142/ debian bash\n#\nFROM\u0009\u0009ubuntu\n\n\nVOLUME\u0009\u0009[/var/cache/apt-cacher-ng]\nRUN\u0009\u0009apt-get update ; apt-get install -yq apt-cacher-ng\n\nEXPOSE \u0009\u00093142\nCMD\u0009\u0009chmod 777 /var/cache/apt-cacher-ng ; /etc/init.d/apt-cacher-ng start ; tail -f /var/log/apt-cacher-ng/*\n",
|
||||||
|
"full_description": "Docker Hub based automated build from a GitHub repo",
|
||||||
|
"is_official": false,
|
||||||
|
"is_private": true,
|
||||||
|
"is_trusted": true,
|
||||||
|
"name": "testhook",
|
||||||
|
"namespace": "svendowideit",
|
||||||
|
"owner": "svendowideit",
|
||||||
|
"repo_name": "svendowideit/testhook",
|
||||||
|
"repo_url": "https://registry.hub.docker.com/u/svendowideit/testhook/",
|
||||||
|
"star_count": 0,
|
||||||
|
"status": "Active"
|
||||||
|
}
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"action": "removed",
|
||||||
|
"installation": {
|
||||||
|
"id": 2,
|
||||||
|
"account": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
},
|
||||||
|
"repository_selection": "selected",
|
||||||
|
"access_tokens_url": "https://api.github.com/installations/2/access_tokens",
|
||||||
|
"repositories_url": "https://api.github.com/installation/repositories",
|
||||||
|
"html_url": "https://github.com/settings/installations/2",
|
||||||
|
"app_id": 5725,
|
||||||
|
"target_id": 3880403,
|
||||||
|
"target_type": "User",
|
||||||
|
"permissions": {
|
||||||
|
"metadata": "read",
|
||||||
|
"contents": "read",
|
||||||
|
"issues": "write"
|
||||||
|
},
|
||||||
|
"events": [
|
||||||
|
"push",
|
||||||
|
"pull_request"
|
||||||
|
],
|
||||||
|
"created_at": 1525109898,
|
||||||
|
"updated_at": 1525109899,
|
||||||
|
"single_file_name": "config.yml"
|
||||||
|
},
|
||||||
|
"repository_selection": "selected",
|
||||||
|
"repositories_added": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"repositories_removed": [
|
||||||
|
{
|
||||||
|
"id": 1296269,
|
||||||
|
"name": "Hello-World",
|
||||||
|
"full_name": "octocat/Hello-World",
|
||||||
|
"private": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sender": {
|
||||||
|
"login": "octocat",
|
||||||
|
"id": 1,
|
||||||
|
"node_id": "MDQ6VXNlcjE=",
|
||||||
|
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id": "",
|
||||||
|
"url": "https://api.github.com/users/octocat",
|
||||||
|
"html_url": "https://github.com/octocat",
|
||||||
|
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||||
|
"type": "User",
|
||||||
|
"site_admin": false
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user