forked from xanzy/go-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_webhook_types.go
1195 lines (1167 loc) · 48.1 KB
/
event_webhook_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright 2021, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package gitlab
import (
"encoding/json"
"fmt"
"strconv"
"time"
)
// StateID identifies the state of an issue or merge request.
//
// There are no GitLab API docs on the subject, but the mappings can be found in
// GitLab's codebase:
// https://gitlab.com/gitlab-org/gitlab-foss/-/blob/ba5be4989e/app/models/concerns/issuable.rb#L39-42
type StateID int
const (
StateIDNone StateID = 0
StateIDOpen StateID = 1
StateIDClosed StateID = 2
StateIDMerged StateID = 3
StateIDLocked StateID = 4
)
// BuildEvent represents a build event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-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"`
BuildCreatedAt string `json:"build_created_at"`
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
User *EventUser `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 int `json:"duration"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
} `json:"commit"`
Repository *Repository `json:"repository"`
}
// CommitCommentEvent represents a comment on a commit event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-a-commit
type CommitCommentEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *User `json:"user"`
ProjectID int `json:"project_id"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
ID int `json:"id"`
Note string `json:"note"`
NoteableType string `json:"noteable_type"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ProjectID int `json:"project_id"`
Attachment string `json:"attachment"`
LineCode string `json:"line_code"`
CommitID string `json:"commit_id"`
NoteableID int `json:"noteable_id"`
System bool `json:"system"`
StDiff *Diff `json:"st_diff"`
Description string `json:"description"`
URL string `json:"url"`
} `json:"object_attributes"`
Commit *struct {
ID string `json:"id"`
Title string `json:"title"`
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"`
}
// DeploymentEvent represents a deployment event
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#deployment-events
type DeploymentEvent struct {
ObjectKind string `json:"object_kind"`
Status string `json:"status"`
StatusChangedAt string `json:"status_changed_at"`
DeploymentID int `json:"deployment_id"`
DeployableID int `json:"deployable_id"`
DeployableURL string `json:"deployable_url"`
Environment string `json:"environment"`
EnvironmentSlug string `json:"environment_slug"`
EnvironmentExternalURL string `json:"environment_external_url"`
Project struct {
ID int `json:"id"`
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"`
CIConfigPath string `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
Ref string `json:"ref"`
ShortSHA string `json:"short_sha"`
User *EventUser `json:"user"`
UserURL string `json:"user_url"`
CommitURL string `json:"commit_url"`
CommitTitle string `json:"commit_title"`
}
// FeatureFlagEvent represents a feature flag event
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#feature-flag-events
type FeatureFlagEvent struct {
ObjectKind string `json:"object_kind"`
Project struct {
ID int `json:"id"`
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"`
CIConfigPath string `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
User *EventUser `json:"user"`
UserURL string `json:"user_url"`
ObjectAttributes struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Active bool `json:"active"`
} `json:"object_attributes"`
}
// IssueCommentEvent represents a comment on an issue event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-an-issue
type IssueCommentEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *User `json:"user"`
ProjectID int `json:"project_id"`
Project struct {
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
ID int `json:"id"`
Note string `json:"note"`
NoteableType string `json:"noteable_type"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ProjectID int `json:"project_id"`
Attachment string `json:"attachment"`
LineCode string `json:"line_code"`
CommitID string `json:"commit_id"`
DiscussionID string `json:"discussion_id"`
NoteableID int `json:"noteable_id"`
System bool `json:"system"`
StDiff []*Diff `json:"st_diff"`
Description string `json:"description"`
URL string `json:"url"`
} `json:"object_attributes"`
Issue struct {
ID int `json:"id"`
IID int `json:"iid"`
ProjectID int `json:"project_id"`
MilestoneID int `json:"milestone_id"`
AuthorID int `json:"author_id"`
Position int `json:"position"`
BranchName string `json:"branch_name"`
Description string `json:"description"`
State string `json:"state"`
Title string `json:"title"`
Labels []*EventLabel `json:"labels"`
LastEditedAt string `json:"last_edit_at"`
LastEditedByID int `json:"last_edited_by_id"`
UpdatedAt string `json:"updated_at"`
UpdatedByID int `json:"updated_by_id"`
CreatedAt string `json:"created_at"`
ClosedAt string `json:"closed_at"`
DueDate *ISOTime `json:"due_date"`
URL string `json:"url"`
TimeEstimate int `json:"time_estimate"`
Confidential bool `json:"confidential"`
TotalTimeSpent int `json:"total_time_spent"`
HumanTotalTimeSpent string `json:"human_total_time_spent"`
HumanTimeEstimate string `json:"human_time_estimate"`
AssigneeIDs []int `json:"assignee_ids"`
AssigneeID int `json:"assignee_id"`
} `json:"issue"`
}
// IssueEvent represents a issue event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#issue-events
type IssueEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *EventUser `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
ID int `json:"id"`
Title string `json:"title"`
AssigneeIDs []int `json:"assignee_ids"`
AssigneeID int `json:"assignee_id"`
AuthorID int `json:"author_id"`
ProjectID int `json:"project_id"`
CreatedAt string `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
UpdatedAt string `json:"updated_at"` // Should be *time.Time (see Gitlab issue #21468)
UpdatedByID int `json:"updated_by_id"`
LastEditedAt string `json:"last_edited_at"`
LastEditedByID int `json:"last_edited_by_id"`
RelativePosition int `json:"relative_position"`
BranchName string `json:"branch_name"`
Description string `json:"description"`
MilestoneID int `json:"milestone_id"`
StateID StateID `json:"state_id"`
Confidential bool `json:"confidential"`
DiscussionLocked bool `json:"discussion_locked"`
DueDate *ISOTime `json:"due_date"`
MovedToID int `json:"moved_to_id"`
DuplicatedToID int `json:"duplicated_to_id"`
TimeEstimate int `json:"time_estimate"`
TotalTimeSpent int `json:"total_time_spent"`
TimeChange int `json:"time_change"`
HumanTotalTimeSpent string `json:"human_total_time_spent"`
HumanTimeEstimate string `json:"human_time_estimate"`
HumanTimeChange string `json:"human_time_change"`
Weight int `json:"weight"`
IID int `json:"iid"`
URL string `json:"url"`
State string `json:"state"`
Action string `json:"action"`
Severity string `json:"severity"`
EscalationStatus string `json:"escalation_status"`
EscalationPolicy struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"escalation_policy"`
Labels []*EventLabel `json:"labels"`
} `json:"object_attributes"`
Assignee *EventUser `json:"assignee"`
Assignees *[]EventUser `json:"assignees"`
Labels []*EventLabel `json:"labels"`
Changes struct {
Assignees struct {
Previous []*EventUser `json:"previous"`
Current []*EventUser `json:"current"`
} `json:"assignees"`
Description struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"description"`
Labels struct {
Previous []*EventLabel `json:"previous"`
Current []*EventLabel `json:"current"`
} `json:"labels"`
Title struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"title"`
ClosedAt struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"closed_at"`
StateID struct {
Previous StateID `json:"previous"`
Current StateID `json:"current"`
} `json:"state_id"`
UpdatedAt struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"updated_at"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
TotalTimeSpent struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"total_time_spent"`
} `json:"changes"`
}
// JobEvent represents a job event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events
type JobEvent 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"`
BuildCreatedAt string `json:"build_created_at"`
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildQueuedDuration float64 `json:"build_queued_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
BuildFailureReason string `json:"build_failure_reason"`
RetriesCount int `json:"retries_count"`
PipelineID int `json:"pipeline_id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
User *EventUser `json:"user"`
Commit struct {
ID int `json:"id"`
Name string `json:"name"`
SHA string `json:"sha"`
Message string `json:"message"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthorURL string `json:"author_url"`
Status string `json:"status"`
Duration int `json:"duration"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
} `json:"commit"`
Repository *Repository `json:"repository"`
Runner struct {
ID int `json:"id"`
Active bool `json:"active"`
RunnerType string `json:"runner_type"`
IsShared bool `json:"is_shared"`
Description string `json:"description"`
Tags []string `json:"tags"`
} `json:"runner"`
Environment struct {
Name string `json:"name"`
Action string `json:"action"`
DeploymentTier string `json:"deployment_tier"`
} `json:"environment"`
}
// MemberEvent represents a member event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#group-member-events
type MemberEvent struct {
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
GroupName string `json:"group_name"`
GroupPath string `json:"group_path"`
GroupID int `json:"group_id"`
UserUsername string `json:"user_username"`
UserName string `json:"user_name"`
UserEmail string `json:"user_email"`
UserID int `json:"user_id"`
GroupAccess string `json:"group_access"`
GroupPlan string `json:"group_plan"`
ExpiresAt *time.Time `json:"expires_at"`
EventName string `json:"event_name"`
}
// MergeCommentEvent represents a comment on a merge event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#comment-on-a-merge-request
type MergeCommentEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *EventUser `json:"user"`
ProjectID int `json:"project_id"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
ObjectAttributes struct {
Attachment string `json:"attachment"`
AuthorID int `json:"author_id"`
ChangePosition *NotePosition `json:"change_position"`
CommitID string `json:"commit_id"`
CreatedAt string `json:"created_at"`
DiscussionID string `json:"discussion_id"`
ID int `json:"id"`
LineCode string `json:"line_code"`
Note string `json:"note"`
NoteableID int `json:"noteable_id"`
NoteableType string `json:"noteable_type"`
OriginalPosition *NotePosition `json:"original_position"`
Position *NotePosition `json:"position"`
ProjectID int `json:"project_id"`
ResolvedAt string `json:"resolved_at"`
ResolvedByID int `json:"resolved_by_id"`
ResolvedByPush bool `json:"resolved_by_push"`
StDiff *Diff `json:"st_diff"`
System bool `json:"system"`
Type string `json:"type"`
UpdatedAt string `json:"updated_at"`
UpdatedByID string `json:"updated_by_id"`
Description string `json:"description"`
URL string `json:"url"`
} `json:"object_attributes"`
Repository *Repository `json:"repository"`
MergeRequest struct {
ID int `json:"id"`
TargetBranch string `json:"target_branch"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
AuthorID int `json:"author_id"`
AssigneeID int `json:"assignee_id"`
AssigneeIDs []int `json:"assignee_ids"`
Title string `json:"title"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
MilestoneID int `json:"milestone_id"`
State string `json:"state"`
MergeStatus string `json:"merge_status"`
TargetProjectID int `json:"target_project_id"`
IID int `json:"iid"`
Description string `json:"description"`
Position int `json:"position"`
Labels []*EventLabel `json:"labels"`
LockedAt string `json:"locked_at"`
UpdatedByID int `json:"updated_by_id"`
MergeError string `json:"merge_error"`
MergeParams *MergeParams `json:"merge_params"`
MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
MergeUserID int `json:"merge_user_id"`
MergeCommitSHA string `json:"merge_commit_sha"`
DeletedAt string `json:"deleted_at"`
InProgressMergeCommitSHA string `json:"in_progress_merge_commit_sha"`
LockVersion int `json:"lock_version"`
ApprovalsBeforeMerge string `json:"approvals_before_merge"`
RebaseCommitSHA string `json:"rebase_commit_sha"`
TimeEstimate int `json:"time_estimate"`
Squash bool `json:"squash"`
LastEditedAt string `json:"last_edited_at"`
LastEditedByID int `json:"last_edited_by_id"`
Source *Repository `json:"source"`
Target *Repository `json:"target"`
LastCommit struct {
ID string `json:"id"`
Title string `json:"title"`
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:"last_commit"`
WorkInProgress bool `json:"work_in_progress"`
TotalTimeSpent int `json:"total_time_spent"`
HeadPipelineID int `json:"head_pipeline_id"`
Assignee *EventUser `json:"assignee"`
DetailedMergeStatus string `json:"detailed_merge_status"`
} `json:"merge_request"`
}
// MergeEvent represents a merge event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events
type MergeEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User *EventUser `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
CIConfigPath string `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
ObjectAttributes struct {
ID int `json:"id"`
TargetBranch string `json:"target_branch"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
AuthorID int `json:"author_id"`
AssigneeID int `json:"assignee_id"`
AssigneeIDs []int `json:"assignee_ids"`
ReviewerIDs []int `json:"reviewer_ids"`
Title string `json:"title"`
CreatedAt string `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
UpdatedAt string `json:"updated_at"` // Should be *time.Time (see Gitlab issue #21468)
StCommits []*Commit `json:"st_commits"`
StDiffs []*Diff `json:"st_diffs"`
LastEditedAt string `json:"last_edited_at"`
LastEditedByID int `json:"last_edited_by_id"`
MilestoneID int `json:"milestone_id"`
StateID StateID `json:"state_id"`
State string `json:"state"`
MergeStatus string `json:"merge_status"`
TargetProjectID int `json:"target_project_id"`
IID int `json:"iid"`
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 *MergeParams `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"`
Target *Repository `json:"target"`
HeadPipelineID *int `json:"head_pipeline_id"`
LastCommit struct {
ID string `json:"id"`
Message string `json:"message"`
Title string `json:"title"`
Timestamp *time.Time `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
} `json:"last_commit"`
BlockingDiscussionsResolved bool `json:"blocking_discussions_resolved"`
WorkInProgress bool `json:"work_in_progress"`
TotalTimeSpent int `json:"total_time_spent"`
TimeChange int `json:"time_change"`
HumanTotalTimeSpent string `json:"human_total_time_spent"`
HumanTimeChange string `json:"human_time_change"`
HumanTimeEstimate string `json:"human_time_estimate"`
FirstContribution bool `json:"first_contribution"`
URL string `json:"url"`
Labels []*EventLabel `json:"labels"`
Action string `json:"action"`
DetailedMergeStatus string `json:"detailed_merge_status"`
OldRev string `json:"oldrev"`
} `json:"object_attributes"`
Repository *Repository `json:"repository"`
Labels []*EventLabel `json:"labels"`
Changes struct {
Assignees struct {
Previous []*EventUser `json:"previous"`
Current []*EventUser `json:"current"`
} `json:"assignees"`
Reviewers struct {
Previous []*EventUser `json:"previous"`
Current []*EventUser `json:"current"`
} `json:"reviewers"`
Description struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"description"`
Labels struct {
Previous []*EventLabel `json:"previous"`
Current []*EventLabel `json:"current"`
} `json:"labels"`
LastEditedAt struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"last_edited_at"`
LastEditedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"last_edited_by_id"`
MilestoneID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"milestone_id"`
SourceBranch struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"source_branch"`
SourceProjectID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"source_project_id"`
StateID struct {
Previous StateID `json:"previous"`
Current StateID `json:"current"`
} `json:"state_id"`
TargetBranch struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"target_branch"`
TargetProjectID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"target_project_id"`
Title struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"title"`
UpdatedAt struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"updated_at"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
} `json:"changes"`
Assignees []*EventUser `json:"assignees"`
Reviewers []*EventUser `json:"reviewers"`
}
// EventUser represents a user record in an event and is used as an even initiator or a merge assignee.
type EventUser struct {
ID int `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Email string `json:"email"`
}
// MergeParams represents the merge params.
type MergeParams struct {
ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
}
// UnmarshalJSON decodes the merge parameters
//
// This allows support of ForceRemoveSourceBranch for both type bool (>11.9) and string (<11.9)
func (p *MergeParams) UnmarshalJSON(b []byte) error {
type Alias MergeParams
raw := struct {
*Alias
ForceRemoveSourceBranch interface{} `json:"force_remove_source_branch"`
}{
Alias: (*Alias)(p),
}
err := json.Unmarshal(b, &raw)
if err != nil {
return err
}
switch v := raw.ForceRemoveSourceBranch.(type) {
case nil:
// No action needed.
case bool:
p.ForceRemoveSourceBranch = v
case string:
p.ForceRemoveSourceBranch, err = strconv.ParseBool(v)
if err != nil {
return err
}
default:
return fmt.Errorf("failed to unmarshal ForceRemoveSourceBranch of type: %T", v)
}
return nil
}
// PipelineEvent represents a pipeline event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#pipeline-events
type PipelineEvent struct {
ObjectKind string `json:"object_kind"`
ObjectAttributes struct {
ID int `json:"id"`
IID int `json:"iid"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
SHA string `json:"sha"`
BeforeSHA string `json:"before_sha"`
Source string `json:"source"`
Status string `json:"status"`
DetailedStatus string `json:"detailed_status"`
Stages []string `json:"stages"`
CreatedAt string `json:"created_at"`
FinishedAt string `json:"finished_at"`
Duration int `json:"duration"`
QueuedDuration int `json:"queued_duration"`
Variables []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"variables"`
} `json:"object_attributes"`
MergeRequest struct {
ID int `json:"id"`
IID int `json:"iid"`
Title string `json:"title"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
TargetBranch string `json:"target_branch"`
TargetProjectID int `json:"target_project_id"`
State string `json:"state"`
MergeRequestStatus string `json:"merge_status"`
DetailedMergeStatus string `json:"detailed_merge_status"`
URL string `json:"url"`
} `json:"merge_request"`
User *EventUser `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Commit struct {
ID string `json:"id"`
Message string `json:"message"`
Title string `json:"title"`
Timestamp *time.Time `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
} `json:"commit"`
SourcePipline struct {
Project struct {
ID int `json:"id"`
WebURL string `json:"web_url"`
PathWithNamespace string `json:"path_with_namespace"`
} `json:"project"`
PipelineID int `json:"pipeline_id"`
JobID int `json:"job_id"`
} `json:"source_pipeline"`
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"`
Duration float64 `json:"duration"`
QueuedDuration float64 `json:"queued_duration"`
FailureReason string `json:"failure_reason"`
When string `json:"when"`
Manual bool `json:"manual"`
AllowFailure bool `json:"allow_failure"`
User *EventUser `json:"user"`
Runner struct {
ID int `json:"id"`
Description string `json:"description"`
Active bool `json:"active"`
IsShared bool `json:"is_shared"`
RunnerType string `json:"runner_type"`
Tags []string `json:"tags"`
} `json:"runner"`
ArtifactsFile struct {
Filename string `json:"filename"`
Size int `json:"size"`
} `json:"artifacts_file"`
Environment struct {
Name string `json:"name"`
Action string `json:"action"`
DeploymentTier string `json:"deployment_tier"`
} `json:"environment"`
} `json:"builds"`
}
// PushEvent represents a push event.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#push-events
type PushEvent struct {
ObjectKind string `json:"object_kind"`
EventName string `json:"event_name"`
Before string `json:"before"`
After string `json:"after"`
Ref string `json:"ref"`
CheckoutSHA string `json:"checkout_sha"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
UserUsername string `json:"user_username"`
UserEmail string `json:"user_email"`
UserAvatar string `json:"user_avatar"`
ProjectID int `json:"project_id"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
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"`
WebURL string `json:"web_url"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
Commits []*struct {
ID string `json:"id"`
Message string `json:"message"`
Title string `json:"title"`
Timestamp *time.Time `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
Added []string `json:"added"`
Modified []string `json:"modified"`
Removed []string `json:"removed"`
} `json:"commits"`
TotalCommitsCount int `json:"total_commits_count"`
}
// ReleaseEvent represents a release event
//
// GitLab API docs:
// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#release-events
type ReleaseEvent struct {
ID int `json:"id"`
CreatedAt string `json:"created_at"` // Should be *time.Time (see Gitlab issue #21468)
Description string `json:"description"`
Name string `json:"name"`
Tag string `json:"tag"`
ReleasedAt string `json:"released_at"` // Should be *time.Time (see Gitlab issue #21468)
ObjectKind string `json:"object_kind"`
Project struct {
ID int `json:"id"`
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"`
CIConfigPath string `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
URL string `json:"url"`
Action string `json:"action"`
Assets struct {
Count int `json:"count"`
Links []struct {
ID int `json:"id"`
External bool `json:"external"`
LinkType string `json:"link_type"`
Name string `json:"name"`
URL string `json:"url"`
} `json:"links"`
Sources []struct {
Format string `json:"format"`
URL string `json:"url"`
} `json:"sources"`
} `json:"assets"`
Commit struct {
ID string `json:"id"`
Message string `json:"message"`
Title string `json:"title"`
Timestamp string `json:"timestamp"` // Should be *time.Time (see Gitlab issue #21468)
URL string `json:"url"`
Author struct {
Name string `json:"name"`