|
1 | 1 | package sdk |
2 | 2 |
|
3 | | -// PushEvent as received from GitHub |
4 | | -type PushEventInstallation struct { |
5 | | - ID int `json:"id"` |
6 | | -} |
7 | | - |
| 3 | +// PushEventRepository represents the repository from a push event |
8 | 4 | type PushEventRepository struct { |
9 | 5 | Name string `json:"name"` |
10 | 6 | FullName string `json:"full_name"` |
11 | 7 | CloneURL string `json:"clone_url"` |
12 | 8 | Private bool `json:"private"` |
| 9 | + ID int64 `json:"id"` |
13 | 10 |
|
14 | 11 | Owner Owner `json:"owner"` |
15 | 12 | } |
16 | 13 |
|
| 14 | +// PushEvent is received from GitHub's push event subscription |
17 | 15 | type PushEvent struct { |
18 | | - SCM string |
19 | 16 | Ref string `json:"ref"` |
20 | 17 | Repository PushEventRepository |
21 | 18 | AfterCommitID string `json:"after"` |
22 | 19 | Installation PushEventInstallation |
| 20 | + SCM string // SCM field is for internal use and not provided by GitHub |
23 | 21 | } |
24 | 22 |
|
25 | 23 | // Owner is the owner of a GitHub repo |
26 | 24 | type Owner struct { |
27 | 25 | Login string `json:"login"` |
28 | 26 | Email string `json:"email"` |
| 27 | + ID int64 `json:"id"` |
29 | 28 | } |
30 | 29 |
|
31 | | -// Event info to pass/store events across functions |
32 | | -type Event struct { |
33 | | - Service string `json:"service"` |
34 | | - Owner string `json:"owner"` |
35 | | - Repository string `json:"repository"` |
36 | | - Image string `json:"image"` |
37 | | - SHA string `json:"sha"` |
38 | | - URL string `json:"url"` |
39 | | - InstallationID int `json:"installationID"` |
40 | | - Environment map[string]string `json:"environment"` |
41 | | - Secrets []string `json:"secrets"` |
42 | | - Private bool `json:"private"` |
43 | | - SCM string `json:"scm"` |
| 30 | +type PushEventInstallation struct { |
| 31 | + ID int `json:"id"` |
44 | 32 | } |
45 | 33 |
|
46 | | -// PushEvent as received from GitLab |
47 | | - |
| 34 | +// GitLabPushEvent as received from GitLab's system hook event |
48 | 35 | type GitLabPushEvent struct { |
49 | 36 | Ref string `json:"ref"` |
50 | 37 | UserUsername string `json:"user_username"` |
@@ -72,19 +59,3 @@ type Customer struct { |
72 | 59 | type Sender struct { |
73 | 60 | Login string `json:"login"` |
74 | 61 | } |
75 | | - |
76 | | -// BuildEventFromPushEvent function to build Event from PushEvent |
77 | | -func BuildEventFromPushEvent(pushEvent PushEvent) *Event { |
78 | | - info := Event{} |
79 | | - |
80 | | - info.Service = pushEvent.Repository.Name |
81 | | - info.Owner = pushEvent.Repository.Owner.Login |
82 | | - info.Repository = pushEvent.Repository.Name |
83 | | - info.URL = pushEvent.Repository.CloneURL |
84 | | - info.Private = pushEvent.Repository.Private |
85 | | - |
86 | | - info.SHA = pushEvent.AfterCommitID |
87 | | - info.InstallationID = pushEvent.Installation.ID |
88 | | - |
89 | | - return &info |
90 | | -} |
0 commit comments