-
Notifications
You must be signed in to change notification settings - Fork 234
/
webhook.go
786 lines (766 loc) · 29.4 KB
/
webhook.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
// Copyright 2017 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gitlab
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
"github.com/drone/go-scm/scm"
)
type webhookService struct {
client *wrapper
}
func (s *webhookService) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhook, error) {
data, err := ioutil.ReadAll(
io.LimitReader(req.Body, 10000000),
)
if err != nil {
return nil, err
}
var hook scm.Webhook
switch req.Header.Get("X-Gitlab-Event") {
case "Push Hook", "Tag Push Hook":
hook, err = parsePushHook(data)
case "Issue Hook":
return nil, scm.ErrUnknownEvent
case "Merge Request Hook":
hook, err = parsePullRequestHook(data)
default:
return nil, scm.ErrUnknownEvent
}
if err != nil {
return nil, err
}
// get the gitlab shared token to verify the payload
// authenticity. If no key is provided, no validation
// is performed.
token, err := fn(hook)
if err != nil {
return hook, err
} else if token == "" {
return hook, nil
}
if token != req.Header.Get("X-Gitlab-Token") {
return hook, scm.ErrSignatureInvalid
}
return hook, nil
}
func parsePushHook(data []byte) (scm.Webhook, error) {
src := new(pushHook)
err := json.Unmarshal(data, src)
if err != nil {
return nil, err
}
switch {
case src.ObjectKind == "push" && src.Before == "0000000000000000000000000000000000000000":
// TODO we previously considered returning a
// branch creation hook, however, the push hook
// returns more metadata (commit details).
return convertPushHook(src), nil
case src.ObjectKind == "push" && src.After == "0000000000000000000000000000000000000000":
return converBranchHook(src), nil
case src.ObjectKind == "tag_push" && src.Before == "0000000000000000000000000000000000000000":
// TODO we previously considered returning a
// tag creation hook, however, the push hook
// returns more metadata (commit details).
return convertPushHook(src), nil
case src.ObjectKind == "tag_push" && src.After == "0000000000000000000000000000000000000000":
return convertTagHook(src), nil
default:
return convertPushHook(src), nil
}
}
func parsePullRequestHook(data []byte) (scm.Webhook, error) {
src := new(pullRequestHook)
err := json.Unmarshal(data, src)
if err != nil {
return nil, err
}
switch src.ObjectAttributes.Action {
case "open", "close", "reopen", "merge", "update":
// no-op
default:
return nil, scm.ErrUnknownEvent
}
switch {
default:
return convertPullRequestHook(src), nil
}
}
func convertPushHook(src *pushHook) *scm.PushHook {
var commits []scm.Commit
for _, c := range src.Commits {
commits = append(commits,
scm.Commit{
Sha: c.ID,
Message: c.Message,
Link: c.URL,
Author: scm.Signature{
Name: c.Author.Name,
Email: c.Author.Email,
},
Committer: scm.Signature{
Name: c.Author.Name,
Email: c.Author.Email,
},
})
}
namespace, name := scm.Split(src.Project.PathWithNamespace)
dst := &scm.PushHook{
Ref: scm.ExpandRef(src.Ref, "refs/heads/"),
Before: src.Before,
After: src.After,
Repo: scm.Repository{
ID: strconv.Itoa(src.Project.ID),
Namespace: namespace,
Name: name,
Clone: src.Project.GitHTTPURL,
CloneSSH: src.Project.GitSSHURL,
Link: src.Project.WebURL,
Branch: src.Project.DefaultBranch,
Private: false, // TODO how do we correctly set Private vs Public?
},
Commit: scm.Commit{
Sha: src.CheckoutSha,
Message: "", // NOTE this is set below
Author: scm.Signature{
Login: src.UserUsername,
Name: src.UserName,
Email: src.UserEmail,
Avatar: src.UserAvatar,
},
Committer: scm.Signature{
Login: src.UserUsername,
Name: src.UserName,
Email: src.UserEmail,
Avatar: src.UserAvatar,
},
Link: "", // NOTE this is set below
},
Sender: scm.User{
Login: src.UserUsername,
Name: src.UserName,
Email: src.UserEmail,
Avatar: src.UserAvatar,
},
Commits: commits,
}
if len(src.Commits) > 0 {
// get the last commit (most recent)
dst.Commit.Message = src.Commits[len(src.Commits)-1].Message
dst.Commit.Link = src.Commits[len(src.Commits)-1].URL
}
return dst
}
func converBranchHook(src *pushHook) *scm.BranchHook {
action := scm.ActionCreate
commit := src.After
if src.After == "0000000000000000000000000000000000000000" {
action = scm.ActionDelete
commit = src.Before
}
namespace, name := scm.Split(src.Project.PathWithNamespace)
return &scm.BranchHook{
Action: action,
Ref: scm.Reference{
Name: scm.TrimRef(src.Ref),
Sha: commit,
},
Repo: scm.Repository{
ID: strconv.Itoa(src.Project.ID),
Namespace: namespace,
Name: name,
Clone: src.Project.GitHTTPURL,
CloneSSH: src.Project.GitSSHURL,
Link: src.Project.WebURL,
Branch: src.Project.DefaultBranch,
Private: false, // TODO how do we correctly set Private vs Public?
},
Sender: scm.User{
Login: src.UserUsername,
Name: src.UserName,
Email: src.UserEmail,
Avatar: src.UserAvatar,
},
}
}
func convertTagHook(src *pushHook) *scm.TagHook {
action := scm.ActionCreate
commit := src.After
if src.After == "0000000000000000000000000000000000000000" {
action = scm.ActionDelete
commit = src.Before
}
namespace, name := scm.Split(src.Project.PathWithNamespace)
return &scm.TagHook{
Action: action,
Ref: scm.Reference{
Name: scm.TrimRef(src.Ref),
Sha: commit,
},
Repo: scm.Repository{
ID: strconv.Itoa(src.Project.ID),
Namespace: namespace,
Name: name,
Clone: src.Project.GitHTTPURL,
CloneSSH: src.Project.GitSSHURL,
Link: src.Project.WebURL,
Branch: src.Project.DefaultBranch,
Private: false, // TODO how do we correctly set Private vs Public?
},
Sender: scm.User{
Login: src.UserUsername,
Name: src.UserName,
Email: src.UserEmail,
Avatar: src.UserAvatar,
},
}
}
func convertPullRequestHook(src *pullRequestHook) *scm.PullRequestHook {
action := scm.ActionSync
switch src.ObjectAttributes.Action {
case "open":
action = scm.ActionOpen
case "close":
action = scm.ActionClose
case "reopen":
action = scm.ActionReopen
case "merge":
action = scm.ActionMerge
case "update":
action = scm.ActionSync
}
fork := scm.Join(
src.ObjectAttributes.Source.Namespace,
src.ObjectAttributes.Source.Name,
)
namespace, name := scm.Split(src.Project.PathWithNamespace)
return &scm.PullRequestHook{
Action: action,
PullRequest: scm.PullRequest{
Number: src.ObjectAttributes.Iid,
Title: src.ObjectAttributes.Title,
Body: src.ObjectAttributes.Description,
Sha: src.ObjectAttributes.LastCommit.ID,
Ref: fmt.Sprintf("refs/merge-requests/%d/head", src.ObjectAttributes.Iid),
Source: src.ObjectAttributes.SourceBranch,
Target: src.ObjectAttributes.TargetBranch,
Fork: fork,
Link: src.ObjectAttributes.URL,
Closed: src.ObjectAttributes.State != "opened",
Merged: src.ObjectAttributes.State == "merged",
// Created : src.ObjectAttributes.CreatedAt,
// Updated : src.ObjectAttributes.UpdatedAt, // 2017-12-10 17:01:11 UTC
Author: scm.User{
Login: src.User.Username,
Name: src.User.Name,
Email: "", // TODO how do we get the pull request author email?
Avatar: src.User.AvatarURL,
},
},
Repo: scm.Repository{
ID: strconv.Itoa(src.Project.ID),
Namespace: namespace,
Name: name,
Clone: src.Project.GitHTTPURL,
CloneSSH: src.Project.GitSSHURL,
Link: src.Project.WebURL,
Branch: src.Project.DefaultBranch,
Private: false, // TODO how do we correctly set Private vs Public?
},
Sender: scm.User{
Login: src.User.Username,
Name: src.User.Name,
Email: "", // TODO how do we get the pull request author email?
Avatar: src.User.AvatarURL,
},
}
}
type (
pushHook 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"`
Message interface{} `json:"message"`
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"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
Commits []struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp string `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
Added []string `json:"added"`
Modified []interface{} `json:"modified"`
Removed []interface{} `json:"removed"`
} `json:"commits"`
TotalCommitsCount int `json:"total_commits_count"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
GitHTTPURL string `json:"git_http_url"`
GitSSHURL string `json:"git_ssh_url"`
VisibilityLevel int `json:"visibility_level"`
} `json:"repository"`
}
commentHook struct {
ObjectKind string `json:"object_kind"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
ProjectID int `json:"project_id"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
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 interface{} `json:"attachment"`
LineCode string `json:"line_code"`
CommitID string `json:"commit_id"`
NoteableID int `json:"noteable_id"`
StDiff interface{} `json:"st_diff"`
System bool `json:"system"`
UpdatedByID interface{} `json:"updated_by_id"`
Type string `json:"type"`
Position struct {
BaseSha string `json:"base_sha"`
StartSha string `json:"start_sha"`
HeadSha string `json:"head_sha"`
OldPath string `json:"old_path"`
NewPath string `json:"new_path"`
PositionType string `json:"position_type"`
OldLine interface{} `json:"old_line"`
NewLine int `json:"new_line"`
} `json:"position"`
OriginalPosition struct {
BaseSha string `json:"base_sha"`
StartSha string `json:"start_sha"`
HeadSha string `json:"head_sha"`
OldPath string `json:"old_path"`
NewPath string `json:"new_path"`
PositionType string `json:"position_type"`
OldLine interface{} `json:"old_line"`
NewLine int `json:"new_line"`
} `json:"original_position"`
ResolvedAt interface{} `json:"resolved_at"`
ResolvedByID interface{} `json:"resolved_by_id"`
DiscussionID string `json:"discussion_id"`
ChangePosition struct {
BaseSha interface{} `json:"base_sha"`
StartSha interface{} `json:"start_sha"`
HeadSha interface{} `json:"head_sha"`
OldPath interface{} `json:"old_path"`
NewPath interface{} `json:"new_path"`
PositionType string `json:"position_type"`
OldLine interface{} `json:"old_line"`
NewLine interface{} `json:"new_line"`
} `json:"change_position"`
ResolvedByPush interface{} `json:"resolved_by_push"`
URL string `json:"url"`
} `json:"object_attributes"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
} `json:"repository"`
MergeRequest struct {
AssigneeID interface{} `json:"assignee_id"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
DeletedAt interface{} `json:"deleted_at"`
Description string `json:"description"`
HeadPipelineID interface{} `json:"head_pipeline_id"`
ID int `json:"id"`
Iid int `json:"iid"`
LastEditedAt interface{} `json:"last_edited_at"`
LastEditedByID interface{} `json:"last_edited_by_id"`
MergeCommitSha interface{} `json:"merge_commit_sha"`
MergeError interface{} `json:"merge_error"`
MergeParams interface{} `json:"-"`
MergeStatus string `json:"merge_status"`
MergeUserID interface{} `json:"merge_user_id"`
MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
MilestoneID interface{} `json:"milestone_id"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
State string `json:"state"`
TargetBranch string `json:"target_branch"`
TargetProjectID int `json:"target_project_id"`
TimeEstimate int `json:"time_estimate"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
UpdatedByID interface{} `json:"updated_by_id"`
URL string `json:"url"`
Source struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"source"`
Target struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"target"`
LastCommit struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp string `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"`
HumanTotalTimeSpent interface{} `json:"human_total_time_spent"`
HumanTimeEstimate interface{} `json:"human_time_estimate"`
} `json:"merge_request"`
}
tagHook 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"`
Message interface{} `json:"message"`
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"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
Commits []struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp string `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
Added []string `json:"added"`
Modified []interface{} `json:"modified"`
Removed []interface{} `json:"removed"`
} `json:"commits"`
TotalCommitsCount int `json:"total_commits_count"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
GitHTTPURL string `json:"git_http_url"`
GitSSHURL string `json:"git_ssh_url"`
VisibilityLevel int `json:"visibility_level"`
} `json:"repository"`
}
issueHook struct {
ObjectKind string `json:"object_kind"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
ObjectAttributes struct {
AssigneeID interface{} `json:"assignee_id"`
AuthorID int `json:"author_id"`
BranchName interface{} `json:"branch_name"`
ClosedAt interface{} `json:"closed_at"`
Confidential bool `json:"confidential"`
CreatedAt string `json:"created_at"`
DeletedAt interface{} `json:"deleted_at"`
Description string `json:"description"`
DueDate interface{} `json:"due_date"`
ID int `json:"id"`
Iid int `json:"iid"`
LastEditedAt string `json:"last_edited_at"`
LastEditedByID int `json:"last_edited_by_id"`
MilestoneID interface{} `json:"milestone_id"`
MovedToID interface{} `json:"moved_to_id"`
ProjectID int `json:"project_id"`
RelativePosition int `json:"relative_position"`
State string `json:"state"`
TimeEstimate int `json:"time_estimate"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
UpdatedByID int `json:"updated_by_id"`
URL string `json:"url"`
TotalTimeSpent int `json:"total_time_spent"`
HumanTotalTimeSpent interface{} `json:"human_total_time_spent"`
HumanTimeEstimate interface{} `json:"human_time_estimate"`
AssigneeIds []interface{} `json:"assignee_ids"`
Action string `json:"action"`
} `json:"object_attributes"`
Labels []struct {
ID int `json:"id"`
Title string `json:"title"`
Color string `json:"color"`
ProjectID int `json:"project_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Template bool `json:"template"`
Description string `json:"description"`
Type string `json:"type"`
GroupID interface{} `json:"group_id"`
} `json:"labels"`
Changes struct {
Labels struct {
Previous []interface{} `json:"previous"`
Current []struct {
ID int `json:"id"`
Title string `json:"title"`
Color string `json:"color"`
ProjectID int `json:"project_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Template bool `json:"template"`
Description string `json:"description"`
Type string `json:"type"`
GroupID interface{} `json:"group_id"`
} `json:"current"`
} `json:"labels"`
} `json:"changes"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
} `json:"repository"`
}
pullRequestHook struct {
ObjectKind string `json:"object_kind"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
ObjectAttributes struct {
AssigneeID interface{} `json:"assignee_id"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
DeletedAt interface{} `json:"deleted_at"`
Description string `json:"description"`
HeadPipelineID interface{} `json:"head_pipeline_id"`
ID int `json:"id"`
Iid int `json:"iid"`
LastEditedAt interface{} `json:"last_edited_at"`
LastEditedByID interface{} `json:"last_edited_by_id"`
MergeCommitSha interface{} `json:"merge_commit_sha"`
MergeError interface{} `json:"merge_error"`
MergeParams interface{} `json:"-"`
MergeStatus string `json:"merge_status"`
MergeUserID interface{} `json:"merge_user_id"`
MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
MilestoneID interface{} `json:"milestone_id"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
State string `json:"state"`
TargetBranch string `json:"target_branch"`
TargetProjectID int `json:"target_project_id"`
TimeEstimate int `json:"time_estimate"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
UpdatedByID interface{} `json:"updated_by_id"`
URL string `json:"url"`
Source struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"source"`
Target struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `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 interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"target"`
LastCommit struct {
ID string `json:"id"`
Message string `json:"message"`
Timestamp string `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"`
HumanTotalTimeSpent interface{} `json:"human_total_time_spent"`
HumanTimeEstimate interface{} `json:"human_time_estimate"`
Action string `json:"action"`
} `json:"object_attributes"`
Labels []interface{} `json:"labels"`
Changes struct {
} `json:"changes"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
} `json:"repository"`
}
)