Skip to content

Commit 1bc47bb

Browse files
authored
chore: update Go version to 1.17 (#182)
1 parent aa8d8a0 commit 1bc47bb

File tree

9 files changed

+60
-62
lines changed

9 files changed

+60
-62
lines changed

azuredevops/azuredevops.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
)
1413

@@ -43,15 +42,15 @@ func New() (*Webhook, error) {
4342
// Parse verifies and parses the events specified and returns the payload object or an error
4443
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
4544
defer func() {
46-
_, _ = io.Copy(ioutil.Discard, r.Body)
45+
_, _ = io.Copy(io.Discard, r.Body)
4746
_ = r.Body.Close()
4847
}()
4948

5049
if r.Method != http.MethodPost {
5150
return nil, ErrInvalidHTTPMethod
5251
}
5352

54-
payload, err := ioutil.ReadAll(r.Body)
53+
payload, err := io.ReadAll(r.Body)
5554
if err != nil || len(payload) == 0 {
5655
return nil, ErrParsingPayload
5756
}

bitbucket-server/bitbucketserver.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
)
1413

@@ -86,7 +85,7 @@ func New(options ...Option) (*Webhook, error) {
8685

8786
func (hook *Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
8887
defer func() {
89-
_, _ = io.Copy(ioutil.Discard, r.Body)
88+
_, _ = io.Copy(io.Discard, r.Body)
9089
_ = r.Body.Close()
9190
}()
9291

@@ -121,7 +120,7 @@ func (hook *Webhook) Parse(r *http.Request, events ...Event) (interface{}, error
121120
return DiagnosticsPingPayload{}, nil
122121
}
123122

124-
payload, err := ioutil.ReadAll(r.Body)
123+
payload, err := io.ReadAll(r.Body)
125124
if err != nil || len(payload) == 0 {
126125
return nil, ErrParsingPayload
127126
}

bitbucket/bitbucket.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109
)
1110

@@ -81,7 +80,7 @@ func New(options ...Option) (*Webhook, error) {
8180
// Parse verifies and parses the events specified and returns the payload object or an error
8281
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
8382
defer func() {
84-
_, _ = io.Copy(ioutil.Discard, r.Body)
83+
_, _ = io.Copy(io.Discard, r.Body)
8584
_ = r.Body.Close()
8685
}()
8786

@@ -120,7 +119,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
120119
return nil, ErrEventNotFound
121120
}
122121

123-
payload, err := ioutil.ReadAll(r.Body)
122+
payload, err := io.ReadAll(r.Body)
124123
if err != nil || len(payload) == 0 {
125124
return nil, ErrParsingPayload
126125
}

docker/docker.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"encoding/json"
1010
"errors"
1111
"io"
12-
"io/ioutil"
1312
"net/http"
1413
)
1514

@@ -69,15 +68,15 @@ func New() (*Webhook, error) {
6968
// Parse verifies and parses the events specified and returns the payload object or an error
7069
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
7170
defer func() {
72-
_, _ = io.Copy(ioutil.Discard, r.Body)
71+
_, _ = io.Copy(io.Discard, r.Body)
7372
_ = r.Body.Close()
7473
}()
7574

7675
if r.Method != http.MethodPost {
7776
return nil, ErrInvalidHTTPMethod
7877
}
7978

80-
payload, err := ioutil.ReadAll(r.Body)
79+
payload, err := io.ReadAll(r.Body)
8180
if err != nil || len(payload) == 0 {
8281
return nil, ErrParsingPayload
8382
}

gitea/gitea.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
)
1413

@@ -85,7 +84,7 @@ func New(options ...Option) (*Webhook, error) {
8584
// Parse verifies and parses the events specified and returns the payload object or an error
8685
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
8786
defer func() {
88-
_, _ = io.Copy(ioutil.Discard, r.Body)
87+
_, _ = io.Copy(io.Discard, r.Body)
8988
_ = r.Body.Close()
9089
}()
9190

@@ -115,7 +114,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
115114
return nil, ErrEventNotFound
116115
}
117116

118-
payload, err := ioutil.ReadAll(r.Body)
117+
payload, err := io.ReadAll(r.Body)
119118
if err != nil || len(payload) == 0 {
120119
return nil, ErrParsingPayload
121120
}

github/github.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
)
1413

@@ -124,7 +123,7 @@ func New(options ...Option) (*Webhook, error) {
124123
// Parse verifies and parses the events specified and returns the payload object or an error
125124
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
126125
defer func() {
127-
_, _ = io.Copy(ioutil.Discard, r.Body)
126+
_, _ = io.Copy(io.Discard, r.Body)
128127
_ = r.Body.Close()
129128
}()
130129

@@ -153,7 +152,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
153152
return nil, ErrEventNotFound
154153
}
155154

156-
payload, err := ioutil.ReadAll(r.Body)
155+
payload, err := io.ReadAll(r.Body)
157156
if err != nil || len(payload) == 0 {
158157
return nil, ErrParsingPayload
159158
}

gitlab/gitlab.go

+39-40
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"net/http"
1211
)
1312

@@ -25,43 +24,43 @@ var (
2524

2625
// GitLab hook types
2726
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"
6564
)
6665

6766
// Option is a configuration option for the webhook
@@ -105,7 +104,7 @@ func New(options ...Option) (*Webhook, error) {
105104
// Parse verifies and parses the events specified and returns the payload object or an error
106105
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
107106
defer func() {
108-
_, _ = io.Copy(ioutil.Discard, r.Body)
107+
_, _ = io.Copy(io.Discard, r.Body)
109108
_ = r.Body.Close()
110109
}()
111110

@@ -131,7 +130,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
131130

132131
gitLabEvent := Event(event)
133132

134-
payload, err := ioutil.ReadAll(r.Body)
133+
payload, err := io.ReadAll(r.Body)
135134
if err != nil || len(payload) == 0 {
136135
return nil, ErrParsingPayload
137136
}

go.mod

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
module github.com/go-playground/webhooks/v6
22

3-
go 1.15
3+
go 1.17
44

55
require (
66
github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355
77
github.com/stretchr/testify v1.6.1
88
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.0 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
14+
)

gogs/gogs.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109

1110
"crypto/hmac"
@@ -77,7 +76,7 @@ func New(options ...Option) (*Webhook, error) {
7776
// Parse verifies and parses the events specified and returns the payload object or an error
7877
func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
7978
defer func() {
80-
_, _ = io.Copy(ioutil.Discard, r.Body)
79+
_, _ = io.Copy(io.Discard, r.Body)
8180
_ = r.Body.Close()
8281
}()
8382

@@ -107,7 +106,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
107106
return nil, ErrEventNotFound
108107
}
109108

110-
payload, err := ioutil.ReadAll(r.Body)
109+
payload, err := io.ReadAll(r.Body)
111110
if err != nil || len(payload) == 0 {
112111
return nil, ErrParsingPayload
113112
}

0 commit comments

Comments
 (0)