7
7
"errors"
8
8
"fmt"
9
9
"io"
10
- "io/ioutil"
11
10
"net/http"
12
11
)
13
12
@@ -25,43 +24,43 @@ var (
25
24
26
25
// GitLab hook types
27
26
const (
28
- PushEvents Event = "Push Hook"
29
- TagEvents Event = "Tag Push Hook"
30
- IssuesEvents Event = "Issue Hook"
31
- ConfidentialIssuesEvents Event = "Confidential Issue Hook"
32
- CommentEvents Event = "Note Hook"
33
- ConfidentialCommentEvents Event = "Confidential Note Hook"
34
- MergeRequestEvents Event = "Merge Request Hook"
35
- WikiPageEvents Event = "Wiki Page Hook"
36
- PipelineEvents Event = "Pipeline Hook"
37
- BuildEvents Event = "Build Hook"
38
- JobEvents Event = "Job Hook"
39
- DeploymentEvents Event = "Deployment Hook"
40
- SystemHookEvents Event = "System Hook"
41
- objectPush string = "push"
42
- objectTag string = "tag_push"
43
- objectMergeRequest string = "merge_request"
44
- objectBuild string = "build"
45
- eventProjectCreate string = "project_create"
46
- eventProjectDestroy string = "project_destroy"
47
- eventProjectRename string = "project_rename"
48
- eventProjectTransfer string = "project_transfer"
49
- eventProjectUpdate string = "project_update"
50
- eventUserAddToTeam string = "user_add_to_team"
51
- eventUserRemoveFromTeam string = "user_remove_from_team"
52
- eventUserUpdateForTeam string = "user_update_for_team"
53
- eventUserCreate string = "user_create"
54
- eventUserDestroy string = "user_destroy"
55
- eventUserFailedLogin string = "user_failed_login"
56
- eventUserRename string = "user_rename"
57
- eventKeyCreate string = "key_create"
58
- eventKeyDestroy string = "key_destroy"
59
- eventGroupCreate string = "group_create"
60
- eventGroupDestroy string = "group_destroy"
61
- eventGroupRename string = "group_rename"
62
- eventUserAddToGroup string = "user_add_to_group"
63
- eventUserRemoveFromGroup string = "user_remove_from_group"
64
- eventUserUpdateForGroup string = "user_update_for_group"
27
+ PushEvents Event = "Push Hook"
28
+ TagEvents Event = "Tag Push Hook"
29
+ IssuesEvents Event = "Issue Hook"
30
+ ConfidentialIssuesEvents Event = "Confidential Issue Hook"
31
+ CommentEvents Event = "Note Hook"
32
+ ConfidentialCommentEvents Event = "Confidential Note Hook"
33
+ MergeRequestEvents Event = "Merge Request Hook"
34
+ WikiPageEvents Event = "Wiki Page Hook"
35
+ PipelineEvents Event = "Pipeline Hook"
36
+ BuildEvents Event = "Build Hook"
37
+ JobEvents Event = "Job Hook"
38
+ DeploymentEvents Event = "Deployment Hook"
39
+ SystemHookEvents Event = "System Hook"
40
+ objectPush string = "push"
41
+ objectTag string = "tag_push"
42
+ objectMergeRequest string = "merge_request"
43
+ objectBuild string = "build"
44
+ eventProjectCreate string = "project_create"
45
+ eventProjectDestroy string = "project_destroy"
46
+ eventProjectRename string = "project_rename"
47
+ eventProjectTransfer string = "project_transfer"
48
+ eventProjectUpdate string = "project_update"
49
+ eventUserAddToTeam string = "user_add_to_team"
50
+ eventUserRemoveFromTeam string = "user_remove_from_team"
51
+ eventUserUpdateForTeam string = "user_update_for_team"
52
+ eventUserCreate string = "user_create"
53
+ eventUserDestroy string = "user_destroy"
54
+ eventUserFailedLogin string = "user_failed_login"
55
+ eventUserRename string = "user_rename"
56
+ eventKeyCreate string = "key_create"
57
+ eventKeyDestroy string = "key_destroy"
58
+ eventGroupCreate string = "group_create"
59
+ eventGroupDestroy string = "group_destroy"
60
+ eventGroupRename string = "group_rename"
61
+ eventUserAddToGroup string = "user_add_to_group"
62
+ eventUserRemoveFromGroup string = "user_remove_from_group"
63
+ eventUserUpdateForGroup string = "user_update_for_group"
65
64
)
66
65
67
66
// Option is a configuration option for the webhook
@@ -105,7 +104,7 @@ func New(options ...Option) (*Webhook, error) {
105
104
// Parse verifies and parses the events specified and returns the payload object or an error
106
105
func (hook Webhook ) Parse (r * http.Request , events ... Event ) (interface {}, error ) {
107
106
defer func () {
108
- _ , _ = io .Copy (ioutil .Discard , r .Body )
107
+ _ , _ = io .Copy (io .Discard , r .Body )
109
108
_ = r .Body .Close ()
110
109
}()
111
110
@@ -131,7 +130,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
131
130
132
131
gitLabEvent := Event (event )
133
132
134
- payload , err := ioutil .ReadAll (r .Body )
133
+ payload , err := io .ReadAll (r .Body )
135
134
if err != nil || len (payload ) == 0 {
136
135
return nil , ErrParsingPayload
137
136
}
0 commit comments