Compare commits

...

26 Commits

Author SHA1 Message Date
Anton Krivenko 3c382736e0 Merge pull request #128 from juliojimenez/checks-installation-id
fix: Add Installation struct to CheckSuitePayload and CheckRunPayload
2021-05-03 23:42:40 +03:00
Anton Krivenko ec227ef416 Merge pull request #131 from riyadhalnur/fix/gitlab-mr-assignee
FIX: gitlab merge request event assignee payload
2021-05-03 23:40:17 +03:00
Riyadh Al Nur e55d994db5 FIX: gitlab merge request event assignee payload
- gitlab updated their MR payload which adds a parent field
for the list of assignees
- this fix update the Assignee struct to add the missing `Email`
and `ID` field
- adds an array of assignees as part of the MR event payload

Closes #101
2021-05-02 16:10:26 +08:00
Julio Jimenez 66bfeb55b9 fix: Add Installation struct to CheckSuitePayload and CheckRunPayload 2021-03-06 14:15:31 -05:00
Anton Krivenko e1c6b6436c Windows support to be checked... 2021-01-23 04:33:26 +03:00
Anton Krivenko 598a1cf5be Fix CI 2021-01-23 04:28:45 +03:00
Anton Krivenko f3cedb24ac Travis -> GitHub Actions 2021-01-23 04:21:20 +03:00
Anton Krivenko 82e53669b8 Fixed tests & minor changes in Makefile 2021-01-23 03:58:58 +03:00
Anton Krivenko cd70db9922 Merge pull request #107 from zrochler/gitlab-job-hook-build-payload
Add handling for job hooks with build payloads
2021-01-21 19:19:31 +03:00
Anton Krivenko b3a37b9b9a Merge pull request #126 from shaheed121/fix_gitlab_payload
Changing duration types from int64 to float64
2021-01-21 19:17:38 +03:00
Anton Krivenko e5ab838da3 Merge pull request #125 from go-playground/v6-go-modules
Go modules support
2021-01-15 00:10:05 +03:00
Abdul Shaheed 56d9dffd38 Changing duration types from int64 to float64 2021-01-11 20:27:51 +01:00
Anton Krivenko c99be7dbb8 CI fixes 2021-01-10 02:10:23 +03:00
Anton Krivenko 433ece5b7b Preparations for the go modules way of work 2021-01-10 01:30:18 +03:00
Anton Krivenko e6bb8aa4b7 Merge pull request #119 from tjrivera/child-team-payload-support
GitHub child team payload support
2021-01-06 22:23:03 +03:00
Anton Krivenko 8a870336ee Merge pull request #110 from wasphin/patch-1
gitlab: fix a typo
2021-01-06 21:54:58 +03:00
Anton Krivenko b6a30802e2 Merge pull request #123 from shaheed121/fix_gitlab_payload
Modify Gitlab Job and Pipeline events
2021-01-06 21:54:45 +03:00
Zach Rochler a8ff1e82b4 Undo BuildDuration change 2021-01-05 16:23:11 -08:00
Anton Krivenko 5fcf4a6e13 Update README.md 2021-01-06 02:47:13 +03:00
Anton Krivenko 1f79ca202d Preparations for the new v6 branch: some updates for .v6 url 2021-01-06 02:33:31 +03:00
Abdul Shaheed b79b935d9e Modify Job and Pipeline events as per https://docs.gitlab.com/ee/user/project/integrations/webhooks.html
Also, modified dependent types like Repository, MergeRequest, Commit to reflect the latest payload.
2020-12-24 11:51:07 +01:00
Xiaofeng Wang fafbb08b19 gitlab: fix a typo 2020-05-26 10:51:49 +08:00
Tyler Rivera c31b74320c Support GitHub child teams in team payload 2020-05-14 11:58:05 -04:00
Tyler Rivera 5be09cefe2 Support GitHub child teams 2020-05-13 17:37:18 -04:00
Zach Rochler cfd9712d30 Fix BuildDuration type 2020-04-15 15:26:28 -07:00
Zach Rochler a7a2c8c856 Add handling for job hooks with build payloads 2020-04-15 14:05:41 -07:00
19 changed files with 507 additions and 347 deletions
+52
View File
@@ -0,0 +1,52 @@
on:
push:
branches:
- master
pull_request:
name: Test
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run linter
uses: golangci/golangci-lint-action@v2
with:
version: v1.35.2
test:
name: Test
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-v1-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-v1-go-
- name: Run tests
run: go test -race -covermode=atomic -coverprofile="coverage.out" ./...
- name: Upload coverage report to Coveralls
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.15.x'
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
+16
View File
@@ -0,0 +1,16 @@
run:
tests: false
skip-dirs:
- _examples
linters:
enable:
- vet
- vetshadow
- golint
- megacheck
- ineffassign
- misspell
- errcheck
- goconst
- gofmt
-34
View File
@@ -1,34 +0,0 @@
language: go
go:
- 1.13.15
- tip
matrix:
allow_failures:
- go: tip
notifications:
email:
recipients: dean.karn@gmail.com
on_success: change
on_failure: always
before_install:
- go get -u github.com/go-playground/overalls
- go get -u github.com/mattn/goveralls
- go get -u golang.org/x/tools/cmd/cover
- mkdir -p $GOPATH/src/gopkg.in
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v2
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v3
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v4
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/webhooks.v5
before_script:
- go get -t ./...
script:
- make test
after_success: |
[ $TRAVIS_GO_VERSION = 1.13.15 ] &&
overalls -project="github.com/go-playground/webhooks" -covermode=count -ignore=.git,_examples,testdata -debug &&
goveralls -coverprofile=overalls.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
+13 -9
View File
@@ -1,17 +1,21 @@
GOCMD=go
GOPATH=$(shell go env GOPATH)
all: lint test
linters-install:
@gometalinter --version >/dev/null 2>&1 || { \
echo "installing linting tools..."; \
$(GOCMD) get github.com/alecthomas/gometalinter; \
gometalinter --install; \
@echo "+ $@"
@$(GOPATH)/bin/golangci-lint --version >/dev/null 2>&1 || { \
echo "Install golangci-lint..."; \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin; \
}
lint: linters-install
@gofmt -l . >gofmt.test 2>&1 && if [ -s gofmt.test ]; then echo "Fix formatting using 'gofmt -s -w .' for:"; cat gofmt.test; exit 1; fi && rm gofmt.test
gometalinter --vendor --disable-all --enable=vet --enable=vetshadow --enable=golint --enable=megacheck --enable=ineffassign --enable=misspell --enable=errcheck --enable=goconst ./...
@echo "+ $@"
$(GOPATH)/bin/golangci-lint run ./...
test:
$(GOCMD) test -cover -race ./...
@echo "+ $@"
GO111MODULE=on go test -covermode=atomic -race ./...
.PHONY: test lint linters-install
.PHONY: test lint linters-install
.DEFAULT_GOAL := all
+8 -8
View File
@@ -1,10 +1,10 @@
Library webhooks
================
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">![Project status](https://img.shields.io/badge/version-5.17.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/webhooks.svg?branch=v5)](https://travis-ci.org/go-playground/webhooks)
[![Coverage Status](https://coveralls.io/repos/go-playground/webhooks/badge.svg?branch=v5&service=github)](https://coveralls.io/github/go-playground/webhooks?branch=v5)
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v6/logo.png">![Project status](https://img.shields.io/badge/version-6.0.0-green.svg)
[![Test](https://github.com/go-playground/webhooks/workflows/Test/badge.svg?branch=master)](https://github.com/go-playground/webhooks/actions)
[![Coverage Status](https://coveralls.io/repos/go-playground/webhooks/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/webhooks?branch=master)
[![Go Report Card](https://goreportcard.com/badge/go-playground/webhooks)](https://goreportcard.com/report/go-playground/webhooks)
[![GoDoc](https://godoc.org/gopkg.in/go-playground/webhooks.v5?status.svg)](https://godoc.org/gopkg.in/go-playground/webhooks.v5)
[![GoDoc](https://godoc.org/github.com/go-playground/webhooks/v6?status.svg)](https://godoc.org/github.com/go-playground/webhooks/v6)
![License](https://img.shields.io/dub/l/vibe-d.svg)
Library webhooks allows for easy receiving and parsing of GitHub, Bitbucket and GitLab Webhook Events
@@ -24,17 +24,17 @@ Installation
Use go get.
```shell
go get -u gopkg.in/go-playground/webhooks.v5
go get -u github.com/go-playground/webhooks/v6
```
Then import the package into your own code.
import "gopkg.in/go-playground/webhooks.v5"
import "github.com/go-playground/webhooks/v6"
Usage and Documentation
------
Please see http://godoc.org/gopkg.in/go-playground/webhooks.v5 for detailed usage docs.
Please see http://godoc.org/github.com/go-playground/webhooks/v6 for detailed usage docs.
##### Examples:
```go
@@ -45,7 +45,7 @@ import (
"net/http"
"gopkg.in/go-playground/webhooks.v5/github"
"github.com/go-playground/webhooks/v6/github"
)
const (
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net/http"
"gopkg.in/go-playground/webhooks.v5/github"
"github.com/go-playground/webhooks/v6/github"
)
const (
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net/http"
"gopkg.in/go-playground/webhooks.v5/github"
"github.com/go-playground/webhooks/v6/github"
)
const (
+6 -6
View File
@@ -147,7 +147,7 @@ type PullRequestCommentAddedPayload struct {
Actor User `json:"actor"`
PullRequest PullRequest `json:"pullRequest"`
Comment Comment `json:"comment"`
CommentParentId uint64 `json:"commentParentId,omitempty"`
CommentParentID uint64 `json:"commentParentId,omitempty"`
}
type PullRequestCommentEditedPayload struct {
@@ -156,7 +156,7 @@ type PullRequestCommentEditedPayload struct {
Actor User `json:"actor"`
PullRequest PullRequest `json:"pullRequest"`
Comment Comment `json:"comment"`
CommentParentId string `json:"commentParentId,omitempty"`
CommentParentID string `json:"commentParentId,omitempty"`
PreviousComment string `json:"previousComment"`
}
@@ -166,7 +166,7 @@ type PullRequestCommentDeletedPayload struct {
Actor User `json:"actor"`
PullRequest PullRequest `json:"pullRequest"`
Comment Comment `json:"comment"`
CommentParentId uint64 `json:"commentParentId,omitempty"`
CommentParentID uint64 `json:"commentParentId,omitempty"`
}
// -----------------------
@@ -186,7 +186,7 @@ type Repository struct {
ID uint64 `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
ScmId string `json:"scmId"`
ScmID string `json:"scmId"`
State string `json:"state"`
StatusMessage string `json:"statusMessage"`
Forkable bool `json:"forkable"`
@@ -229,7 +229,7 @@ type PullRequest struct {
type RepositoryChange struct {
Reference RepositoryReference `json:"ref"`
ReferenceId string `json:"refId"`
ReferenceID string `json:"refId"`
FromHash string `json:"fromHash"`
ToHash string `json:"toHash"`
Type string `json:"type"`
@@ -237,7 +237,7 @@ type RepositoryChange struct {
type RepositoryReference struct {
ID string `json:"id"`
DisplayId string `json:"displayId"`
DisplayID string `json:"displayId"`
Type string `json:"type,omitempty"`
LatestCommit string `json:"latestCommit,omitempty"`
Repository Repository `json:"repository,omitempty"`
+1 -1
View File
@@ -350,7 +350,7 @@ type Owner struct {
Type string `json:"type"`
NickName string `json:"nickname"`
DisplayName string `json:"display_name"`
AccountId string `json:"account_id"`
AccountID string `json:"account_id"`
UUID string `json:"uuid"`
Links struct {
Self struct {
+1 -2
View File
@@ -1,6 +1,6 @@
package docker
// this package recieves the Docker Hub Automated Build webhook
// this package receives 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/
@@ -58,7 +58,6 @@ type BuildPayload struct {
// Webhook instance contains all methods needed to process events
type Webhook struct {
secret string
}
// New creates and returns a WebHook instance
+27 -38
View File
@@ -13,7 +13,7 @@ type CheckRunPayload struct {
Status string `json:"status"`
Conclusion string `json:"conclusion"`
URL string `json:"url"`
HtmlURL string `json:"html_url"`
HTMLURL string `json:"html_url"`
StarterAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
Output struct {
@@ -59,7 +59,7 @@ type CheckRunPayload struct {
Name string `json:"name"`
Description string `json:"description"`
ExternalURL string `json:"external_url"`
HtmlURL string `json:"html_url"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
} `json:"app"`
@@ -92,7 +92,7 @@ type CheckRunPayload struct {
Name string `json:"name"`
Description string `json:"description"`
ExternalURL string `json:"external_url"`
HtmlURL string `json:"html_url"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
} `json:"app"`
@@ -187,6 +187,9 @@ type CheckRunPayload struct {
Watchers int64 `json:"watchers"`
DefaultBranch string `json:"default_branch"`
} `json:"repository"`
Installation struct {
ID int64 `json:"id"`
} `json:"installation,omitempty"`
Sender struct {
Login string `json:"login"`
ID int64 `json:"id"`
@@ -249,7 +252,7 @@ type CheckSuitePayload struct {
Name string `json:"name"`
Description string `json:"description"`
ExternalURL string `json:"external_url"`
HtmlURL string `json:"html_url"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
} `json:"app"`
@@ -359,6 +362,9 @@ type CheckSuitePayload struct {
Watchers int64 `json:"watchers"`
DefaultBranch string `json:"default_branch"`
} `json:"repository"`
Installation struct {
ID int64 `json:"id"`
} `json:"installation,omitempty"`
Sender struct {
Login string `json:"login"`
ID int64 `json:"id"`
@@ -2267,16 +2273,7 @@ type MembershipPayload struct {
Type string `json:"type"`
SiteAdmin bool `json:"site_admin"`
} `json:"sender"`
Team struct {
Name string `json:"name"`
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Slug string `json:"slug"`
Permission string `json:"permission"`
URL string `json:"url"`
MembersURL string `json:"members_url"`
RepositoriesURL string `json:"repositories_url"`
} `json:"team"`
Team *Team `json:"team"`
Organization struct {
Login string `json:"login"`
ID int64 `json:"id"`
@@ -5693,19 +5690,8 @@ type StatusPayload struct {
// TeamPayload contains the information for GitHub's team hook event
type TeamPayload struct {
Action string `json:"action"`
Team struct {
Name string `json:"name"`
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Slug string `json:"slug"`
Description string `json:"description"`
Privacy string `json:"privacy"`
URL string `json:"url"`
MembersURL string `json:"members_url"`
RepositoriesURL string `json:"repositories_url"`
Permission string `json:"permission"`
} `json:"team"`
Action string `json:"action"`
Team *Team `json:"team"`
Organization struct {
Login string `json:"login"`
ID int64 `json:"id"`
@@ -5744,17 +5730,7 @@ type TeamPayload struct {
// TeamAddPayload contains the information for GitHub's team_add hook event
type TeamAddPayload struct {
Team struct {
Name string `json:"name"`
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Slug string `json:"slug"`
Description string `json:"description"`
Permission string `json:"permission"`
URL string `json:"url"`
MembersURL string `json:"members_url"`
RepositoriesURL string `json:"repositories_url"`
} `json:"team"`
Team *Team `json:"team"`
Repository struct {
ID int64 `json:"id"`
NodeID string `json:"node_id"`
@@ -6126,3 +6102,16 @@ type Label struct {
Color string `json:"color"`
Default bool `json:"default"`
}
// Team contains GitHub's Team information
type Team struct {
Name string `json:"name"`
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Slug string `json:"slug"`
Permission string `json:"permission"`
URL string `json:"url"`
MembersURL string `json:"members_url"`
RepositoriesURL string `json:"repositories_url"`
Parent *Team `json:"parent,omitempty"`
}
+10 -3
View File
@@ -38,6 +38,7 @@ const (
objectPush string = "push"
objectTag string = "tag_push"
objectMergeRequest string = "merge_request"
objectBuild string = "build"
)
// Option is a configuration option for the webhook
@@ -173,9 +174,15 @@ func eventParsing(gitLabEvent Event, events []Event, payload []byte) (interface{
err := json.Unmarshal([]byte(payload), &pl)
return pl, err
case JobEvents:
var p1 JobEventPayload
err := json.Unmarshal([]byte(payload), &p1)
return p1, err
var pl JobEventPayload
err := json.Unmarshal([]byte(payload), &pl)
if err != nil {
return nil, err
}
if pl.ObjectKind == objectBuild {
return eventParsing(BuildEvents, events, payload)
}
return pl, nil
case SystemHookEvents:
var pl SystemHookPayload
+47 -4
View File
@@ -231,11 +231,54 @@ func TestWebhooks(t *testing.T) {
"X-Gitlab-Event": []string{"Build Hook"},
},
},
}
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 = tc.headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Gitlab-Token", "sampleToken!")
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))
})
}
}
func TestJobHooks(t *testing.T) {
assert := require.New(t)
tests := []struct {
name string
events []Event
typ interface{}
filename string
headers http.Header
}{
{
name: "JobEvent",
event: JobEvents,
typ: JobEventPayload{},
filename: "../testdata/gitlab/job-event.json",
events: []Event{JobEvents, BuildEvents},
typ: BuildEventPayload{},
filename: "../testdata/gitlab/build-event.json",
headers: http.Header{
"X-Gitlab-Event": []string{"Job Hook"},
},
@@ -256,7 +299,7 @@ func TestWebhooks(t *testing.T) {
var parseError error
var results interface{}
server := newServer(func(w http.ResponseWriter, r *http.Request) {
results, parseError = hook.Parse(r, tc.event)
results, parseError = hook.Parse(r, tc.events...)
})
defer server.Close()
req, err := http.NewRequest(http.MethodPost, server.URL+path, payload)
+61 -34
View File
@@ -57,6 +57,7 @@ type MergeRequestEventPayload struct {
Project Project `json:"project"`
Repository Repository `json:"repository"`
Labels []Label `json:"labels"`
Assignees []Assignee `json:"assignees"`
}
// PushEventPayload contains the information for GitLab's push event
@@ -112,7 +113,8 @@ type PipelineEventPayload struct {
Project Project `json:"project"`
Commit Commit `json:"commit"`
ObjectAttributes PipelineObjectAttributes `json:"object_attributes"`
Jobs []Job `json:"jobs"`
MergeRequest MergeRequest `json:"merge_request"`
Builds []Build `json:"builds"`
}
// CommentEventPayload contains the information for GitLab's comment event
@@ -142,7 +144,7 @@ type BuildEventPayload struct {
BuildStatus string `json:"build_status"`
BuildStartedAt customTime `json:"build_started_at"`
BuildFinishedAt customTime `json:"build_finished_at"`
BuildDuration int64 `json:"build_duration"`
BuildDuration float64 `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
ProjectID int64 `json:"project_id"`
ProjectName string `json:"project_name"`
@@ -153,25 +155,27 @@ type BuildEventPayload struct {
// JobEventPayload contains the information for GitLab's Job status change
type JobEventPayload struct {
ObjectKind string `json:"object_kind"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
BeforeSHA string `json:"before_sha"`
SHA string `json:"sha"`
JobID int64 `json:"Job_id"`
JobName string `json:"Job_name"`
JobStage string `json:"Job_stage"`
JobStatus string `json:"Job_status"`
JobStartedAt customTime `json:"Job_started_at"`
JobFinishedAt customTime `json:"Job_finished_at"`
JobDuration int64 `json:"Job_duration"`
Job bool `json:"Job"`
JobFailureReason string `json:"job_failure_reason"`
ProjectID int64 `json:"project_id"`
ProjectName string `json:"project_name"`
User User `json:"user"`
Commit BuildCommit `json:"commit"`
Repository Repository `json:"repository"`
ObjectKind string `json:"object_kind"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
BeforeSHA string `json:"before_sha"`
SHA string `json:"sha"`
BuildID int64 `json:"build_id"`
BuildName string `json:"build_name"`
BuildStage string `json:"build_stage"`
BuildStatus string `json:"build_status"`
BuildStartedAt customTime `json:"build_started_at"`
BuildFinishedAt customTime `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
BuildFailureReason string `json:"build_failure_reason"`
PipelineID int64 `json:"pipeline_id"`
ProjectID int64 `json:"project_id"`
ProjectName string `json:"project_name"`
User User `json:"user"`
Commit BuildCommit `json:"commit"`
Repository Repository `json:"repository"`
Runner Runner `json:"runner"`
}
// SystemHookPayload contains the ObjectKind to match with real hook events
@@ -197,8 +201,8 @@ type Issue struct {
IID int64 `json:"iid"`
}
// Job contains all of the GitLab job information
type Job struct {
// Build contains all of the GitLab Build information
type Build struct {
ID int64 `json:"id"`
Stage string `json:"stage"`
Name string `json:"name"`
@@ -240,6 +244,7 @@ type Wiki struct {
type Commit struct {
ID string `json:"id"`
Message string `json:"message"`
Title string `json:"title"`
Timestamp customTime `json:"timestamp"`
URL string `json:"url"`
Author Author `json:"author"`
@@ -253,10 +258,10 @@ type BuildCommit struct {
ID int64 `json:"id"`
SHA string `json:"sha"`
Message string `json:"message"`
AuthorName string `json:"auuthor_name"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
Status string `json:"status"`
Duration int64 `json:"duration"`
Duration float64 `json:"duration"`
StartedAt customTime `json:"started_at"`
FinishedAt customTime `json:"finished_at"`
}
@@ -290,7 +295,7 @@ type Project struct {
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL string `json:"avatar_url"`
GitSSSHURL string `json:"git_ssh_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int64 `json:"visibility_level"`
@@ -304,28 +309,40 @@ type Project struct {
// Repository contains all of the GitLab repository information
type Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
VisibilityLevel int64 `json:"visibility_level"`
}
// ObjectAttributes contains all of the GitLab object attributes information
type ObjectAttributes struct {
ID int64 `json:"id"`
Title string `json:"title"`
AssigneeIDS []int64 `json:"assignee_ids"`
AssigneeID int64 `json:"assignee_id"`
AuthorID int64 `json:"author_id"`
ProjectID int64 `json:"project_id"`
CreatedAt customTime `json:"created_at"`
UpdatedAt customTime `json:"updated_at"`
ChangePosition Position `json:"change_position"`
OriginalPosition Position `json:"original_position"`
UpdatedByID int64 `json:"updated_by_id"`
LastEditedAt customTime `json:"last_edited_at"`
LastEditedByID int64 `json:"last_edited_by_id"`
RelativePosition int64 `json:"relative_position"`
Position Position `json:"position"`
BranchName string `json:"branch_name"`
Description string `json:"description"`
MilestoneID int64 `json:"milestone_id"`
State string `json:"state"`
StateID int64 `json:"state_id"`
Confidential bool `json:"confidential"`
DiscussionLocked bool `json:"discussion_locked"`
DueDate customTime `json:"due_date"`
TimeEstimate int64 `json:"time_estimate"`
TotalTimeSpent int64 `json:"total_time_spent"`
IID int64 `json:"iid"`
URL string `json:"url"`
Action string `json:"action"`
@@ -347,11 +364,11 @@ type ObjectAttributes struct {
Stages []string `json:"stages"`
Duration int64 `json:"duration"`
Note string `json:"note"`
NotebookType string `json:"noteable_type"`
NotebookType string `json:"noteable_type"` // nolint:misspell
At customTime `json:"attachment"`
LineCode string `json:"line_code"`
CommitID string `json:"commit_id"`
NoteableID int64 `json:"noteable_id"`
NoteableID int64 `json:"noteable_id"` // nolint: misspell
System bool `json:"system"`
WorkInProgress bool `json:"work_in_progress"`
StDiffs []StDiff `json:"st_diffs"`
@@ -374,6 +391,13 @@ type PipelineObjectAttributes struct {
CreatedAt customTime `json:"created_at"`
FinishedAt customTime `json:"finished_at"`
Duration int64 `json:"duration"`
Variables []Variable `json:"variables"`
}
// Variable contains pipeline variables
type Variable struct {
Key string `json:"key"`
Value string `json:"value"`
}
// Position defines a specific location, identified by paths line numbers and
@@ -421,13 +445,16 @@ type MergeRequest struct {
LastCommit LastCommit `json:"last_commit"`
WorkInProgress bool `json:"work_in_progress"`
Assignee Assignee `json:"assignee"`
URL string `json:"url"`
}
// Assignee contains all of the GitLab assignee information
type Assignee struct {
ID int64 `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Email string `json:"email"`
}
// StDiff contains all of the GitLab diff information
+8
View File
@@ -0,0 +1,8 @@
module github.com/go-playground/webhooks/v6
go 1.15
require (
github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355
github.com/stretchr/testify v1.6.1
)
+13
View File
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355 h1:HTVNOdTWO/gHYeFnr/HwpYwY6tgMcYd+Rgf1XrHnORY=
github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355/go.mod h1:cY2AIrMgHm6oOHmR7jY+9TtjzSjQ3iG7tURJG3Y6XH0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+47 -39
View File
@@ -1,42 +1,50 @@
{
"object_kind": "job",
"ref": "gitlab-script-trigger",
"tag": false,
"before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"object_kind": "build",
"ref": "gitlab-script-trigger",
"tag": false,
"before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"build_id": 1977,
"build_name": "test",
"build_stage": "test",
"build_status": "created",
"build_started_at": null,
"build_finished_at": null,
"build_duration": null,
"build_allow_failure": false,
"build_failure_reason": "script_failure",
"pipeline_id": 2366,
"project_id": 380,
"project_name": "gitlab-org/gitlab-test",
"user": {
"id": 3,
"name": "User",
"email": "user@gitlab.com",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"commit": {
"id": 2366,
"sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"job_id": 1977,
"job_name": "test",
"job_stage": "test",
"job_status": "created",
"job_started_at": null,
"job_finished_at": null,
"job_duration": null,
"job_allow_failure": false,
"job_failure_reason": "script_failure",
"project_id": 380,
"project_name": "gitlab-org/gitlab-test",
"user": {
"id": 3,
"name": "User",
"email": "user@gitlab.com"
},
"commit": {
"id": 2366,
"sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"message": "test\n",
"author_name": "User",
"author_email": "user@gitlab.com",
"status": "created",
"duration": null,
"started_at": null,
"finished_at": null
},
"repository": {
"name": "gitlab_test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"visibility_level": 20
}
"message": "test\n",
"author_name": "User",
"author_email": "user@gitlab.com",
"status": "created",
"duration": null,
"started_at": null,
"finished_at": null
},
"repository": {
"name": "gitlab_test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"visibility_level": 20
},
"runner": {
"active": true,
"is_shared": false,
"id": 380987,
"description": "shared-runners-manager-6.gitlab.com"
}
}
+10 -1
View File
@@ -136,5 +136,14 @@
"group_id": 41
}]
}
}
},
"assignees": [
{
"id": 6,
"name": "User1",
"username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "user1@gmail.com"
}
]
}
+185 -166
View File
@@ -1,175 +1,194 @@
{
"object_kind": "pipeline",
"object_attributes":{
"id": 31,
"ref": "master",
"tag": false,
"sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"before_sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"status": "success",
"stages":[
"build",
"test",
"deploy"
],
"created_at": "2016-08-12 15:23:28 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
"duration": 63,
"variables": [
{
"key": "NESTOR_PROD_ENVIRONMENT",
"value": "us-west-1"
}
]
},
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"project":{
"id": 1,
"name": "Gitlab Test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"avatar_url": null,
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"namespace": "Gitlab Org",
"visibility_level": 20,
"path_with_namespace": "gitlab-org/gitlab-test",
"default_branch": "master"
},
"commit":{
"id": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"message": "test\n",
"timestamp": "2016-08-12T17:23:21+02:00",
"url": "http://example.com/gitlab-org/gitlab-test/commit/bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"author":{
"name": "User",
"email": "user@gitlab.com"
}
},
"jobs":[
{
"id": 380,
"stage": "deploy",
"name": "production",
"status": "skipped",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "manual",
"manual": true,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 377,
"stage": "test",
"name": "test-image",
"object_kind": "pipeline",
"object_attributes":{
"id": 31,
"ref": "master",
"tag": false,
"sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"before_sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"source": "merge_request_event",
"status": "success",
"stages":[
"build",
"test",
"deploy"
],
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": null,
"when": "on_success",
"manual": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 378,
"stage": "test",
"name": "test-build",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
"when": "on_success",
"manual": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
"artifacts_file":{
"filename": null,
"size": null
"duration": 63,
"variables": [
{
"key": "NESTOR_PROD_ENVIRONMENT",
"value": "us-west-1"
}
]
},
"merge_request": {
"id": 1,
"iid": 1,
"title": "Test",
"source_branch": "test",
"source_project_id": 1,
"target_branch": "master",
"target_project_id": 1,
"state": "opened",
"merge_status": "can_be_merged",
"url": "http://192.168.64.1:3005/gitlab-org/gitlab-test/merge_requests/1"
},
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "user_email@gitlab.com"
},
"project":{
"id": 1,
"name": "Gitlab Test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"avatar_url": null,
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"namespace": "Gitlab Org",
"visibility_level": 20,
"path_with_namespace": "gitlab-org/gitlab-test",
"default_branch": "master"
},
"commit":{
"id": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"message": "test\n",
"timestamp": "2016-08-12T17:23:21+02:00",
"url": "http://example.com/gitlab-org/gitlab-test/commit/bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"author":{
"name": "User",
"email": "user@gitlab.com"
}
},
{
"id": 376,
"stage": "build",
"name": "build-image",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:24:56 UTC",
"finished_at": "2016-08-12 15:25:26 UTC",
"when": "on_success",
"manual": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"builds":[
{
"id": 380,
"stage": "deploy",
"name": "production",
"status": "skipped",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "manual",
"manual": true,
"allow_failure": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
{
"id": 377,
"stage": "test",
"name": "test-image",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": null,
"when": "on_success",
"manual": false,
"allow_failure": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
"artifacts_file":{
"filename": null,
"size": null
}
},
"artifacts_file":{
"filename": null,
"size": null
{
"id": 378,
"stage": "test",
"name": "test-build",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
"when": "on_success",
"manual": false,
"allow_failure": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 376,
"stage": "build",
"name": "build-image",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:24:56 UTC",
"finished_at": "2016-08-12 15:25:26 UTC",
"when": "on_success",
"manual": false,
"allow_failure": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 379,
"stage": "deploy",
"name": "staging",
"status": "created",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "on_success",
"manual": false,
"allow_failure": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
}
},
{
"id": 379,
"stage": "deploy",
"name": "staging",
"status": "created",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "on_success",
"manual": false,
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
}
]
]
}