Commit 507dedeb authored by Mustafa YILDIRIM's avatar Mustafa YILDIRIM Committed by Sander van Harmelen

PipelineEvent type changed (#99)

* PipelineEvent type changed

* Added BuildEvent

* fixing typo

* Refactoring with existing struct type

* Fixed different type object form

* fixing auto generated interface types to string

* Added PushEvent, MergeRequestEvent, PipelineEvent, BuildEvent unmarshal test

* Added GroupMergeEvent type

* Remove GroupMergeEvent and fix MergeEvent for Group Webhooks
parent 5e291322
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package gitlab package gitlab
import "time"
// PushEvent represents a push event. // PushEvent represents a push event.
// //
// GitLab API docs: // GitLab API docs:
...@@ -236,6 +238,22 @@ type SnippetCommentEvent struct { ...@@ -236,6 +238,22 @@ type SnippetCommentEvent struct {
type MergeEvent struct { type MergeEvent struct {
ObjectKind string `json:"object_kind"` ObjectKind string `json:"object_kind"`
User *User `json:"user"` User *User `json:"user"`
Project struct {
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel VisibilityLevelValue `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
ObjectAttributes struct { ObjectAttributes struct {
ID int `json:"id"` ID int `json:"id"`
TargetBranch string `json:"target_branch"` TargetBranch string `json:"target_branch"`
...@@ -254,9 +272,31 @@ type MergeEvent struct { ...@@ -254,9 +272,31 @@ type MergeEvent struct {
TargetProjectID int `json:"target_project_id"` TargetProjectID int `json:"target_project_id"`
Iid int `json:"iid"` Iid int `json:"iid"`
Description string `json:"description"` Description string `json:"description"`
Position int `json:"position"`
LockedAt string `json:"locked_at"`
UpdatedByID int `json:"updated_by_id"`
MergeError string `json:"merge_error"`
MergeParams struct {
ForceRemoveSourceBranch string `json:"force_remove_source_branch"`
} `json:"merge_params"`
MergeWhenBuildSucceeds bool `json:"merge_when_build_succeeds"`
MergeUserID int `json:"merge_user_id"`
MergeCommitSha string `json:"merge_commit_sha"`
DeletedAt string `json:"deleted_at"`
ApprovalsBeforeMerge string `json:"approvals_before_merge"`
RebaseCommitSha string `json:"rebase_commit_sha"`
InProgressMergeCommitSha string `json:"in_progress_merge_commit_sha"`
LockVersion int `json:"lock_version"`
TimeEstimate int `json:"time_estimate"`
Source *Repository `json:"source"` Source *Repository `json:"source"`
Target *Repository `json:"target"` Target *Repository `json:"target"`
LastCommit *Commit `json:"last_commit"` LastCommit struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp *time.Time `json:"timestamp"`
URL string `json:"url"`
Author *Author `json:"author"`
} `json:"last_commit"`
WorkInProgress bool `json:"work_in_progress"` WorkInProgress bool `json:"work_in_progress"`
URL string `json:"url"` URL string `json:"url"`
Action string `json:"action"` Action string `json:"action"`
...@@ -266,6 +306,12 @@ type MergeEvent struct { ...@@ -266,6 +306,12 @@ type MergeEvent struct {
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
} `json:"assignee"` } `json:"assignee"`
} `json:"object_attributes"` } `json:"object_attributes"`
Repository *Repository `json:"repository"`
Assignee struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"assignee"`
} }
// WikiPageEvent represents a wiki page event. // WikiPageEvent represents a wiki page event.
...@@ -294,7 +340,7 @@ type WikiPageEvent struct { ...@@ -294,7 +340,7 @@ type WikiPageEvent struct {
} `json:"object_attributes"` } `json:"object_attributes"`
} }
// PipelineEvent represents a pipline event. // PipelineEvent represents a pipeline event.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/web_hooks/web_hooks.html#pipeline-events // https://docs.gitlab.com/ce/web_hooks/web_hooks.html#pipeline-events
...@@ -312,8 +358,91 @@ type PipelineEvent struct { ...@@ -312,8 +358,91 @@ type PipelineEvent struct {
FinishedAt string `json:"finished_at"` FinishedAt string `json:"finished_at"`
Duration int `json:"duration"` Duration int `json:"duration"`
} `json:"object_attributes"` } `json:"object_attributes"`
User *User `json:"user"` User struct {
Project *Project `json:"project"` Name string `json:"name"`
Commit *Commit `json:"commit"` Username string `json:"username"`
Builds []*Build `json:"builds"` AvatarURL string `json:"avatar_url"`
} `json:"user"`
Project struct {
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
} `json:"project"`
Commit struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
} `json:"commit"`
Builds []struct {
ID int `json:"id"`
Stage string `json:"stage"`
Name string `json:"name"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
When string `json:"when"`
Manual bool `json:"manual"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
Runner string `json:"runner"`
ArtifactsFile struct {
Filename string `json:"filename"`
Size string `json:"size"`
} `json:"artifacts_file"`
} `json:"builds"`
}
//BuildEvent represents a build event
//
// GitLab API docs:
// https://docs.gitlab.com/ce/web_hooks/web_hooks.html#build-events
type BuildEvent struct {
ObjectKind string `json:"object_kind"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
BeforeSha string `json:"before_sha"`
Sha string `json:"sha"`
BuildID int `json:"build_id"`
BuildName string `json:"build_name"`
BuildStage string `json:"build_stage"`
BuildStatus string `json:"build_status"`
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration string `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
} `json:"user"`
Commit struct {
ID int `json:"id"`
Sha string `json:"sha"`
Message string `json:"message"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
Status string `json:"status"`
Duration string `json:"duration"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
} `json:"commit"`
Repository *Repository `json:"repository"`
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment