Skip to content

Commit

Permalink
chore: update Go version to 1.17 (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlieb committed Oct 5, 2023
1 parent aa8d8a0 commit 1bc47bb
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 62 deletions.
5 changes: 2 additions & 3 deletions azuredevops/azuredevops.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

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

if r.Method != http.MethodPost {
return nil, ErrInvalidHTTPMethod
}

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
5 changes: 2 additions & 3 deletions bitbucket-server/bitbucketserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

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

func (hook *Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) {
defer func() {
_, _ = io.Copy(ioutil.Discard, r.Body)
_, _ = io.Copy(io.Discard, r.Body)
_ = r.Body.Close()
}()

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

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
5 changes: 2 additions & 3 deletions bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

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

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

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
5 changes: 2 additions & 3 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/json"
"errors"
"io"
"io/ioutil"
"net/http"
)

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

if r.Method != http.MethodPost {
return nil, ErrInvalidHTTPMethod
}

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
5 changes: 2 additions & 3 deletions gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

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

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

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
5 changes: 2 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

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

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

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
79 changes: 39 additions & 40 deletions gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
)

Expand All @@ -25,43 +24,43 @@ var (

// GitLab hook types
const (
PushEvents Event = "Push Hook"
TagEvents Event = "Tag Push Hook"
IssuesEvents Event = "Issue Hook"
ConfidentialIssuesEvents Event = "Confidential Issue Hook"
CommentEvents Event = "Note Hook"
ConfidentialCommentEvents Event = "Confidential Note Hook"
MergeRequestEvents Event = "Merge Request Hook"
WikiPageEvents Event = "Wiki Page Hook"
PipelineEvents Event = "Pipeline Hook"
BuildEvents Event = "Build Hook"
JobEvents Event = "Job Hook"
DeploymentEvents Event = "Deployment Hook"
SystemHookEvents Event = "System Hook"
objectPush string = "push"
objectTag string = "tag_push"
objectMergeRequest string = "merge_request"
objectBuild string = "build"
eventProjectCreate string = "project_create"
eventProjectDestroy string = "project_destroy"
eventProjectRename string = "project_rename"
eventProjectTransfer string = "project_transfer"
eventProjectUpdate string = "project_update"
eventUserAddToTeam string = "user_add_to_team"
eventUserRemoveFromTeam string = "user_remove_from_team"
eventUserUpdateForTeam string = "user_update_for_team"
eventUserCreate string = "user_create"
eventUserDestroy string = "user_destroy"
eventUserFailedLogin string = "user_failed_login"
eventUserRename string = "user_rename"
eventKeyCreate string = "key_create"
eventKeyDestroy string = "key_destroy"
eventGroupCreate string = "group_create"
eventGroupDestroy string = "group_destroy"
eventGroupRename string = "group_rename"
eventUserAddToGroup string = "user_add_to_group"
eventUserRemoveFromGroup string = "user_remove_from_group"
eventUserUpdateForGroup string = "user_update_for_group"
PushEvents Event = "Push Hook"
TagEvents Event = "Tag Push Hook"
IssuesEvents Event = "Issue Hook"
ConfidentialIssuesEvents Event = "Confidential Issue Hook"
CommentEvents Event = "Note Hook"
ConfidentialCommentEvents Event = "Confidential Note Hook"
MergeRequestEvents Event = "Merge Request Hook"
WikiPageEvents Event = "Wiki Page Hook"
PipelineEvents Event = "Pipeline Hook"
BuildEvents Event = "Build Hook"
JobEvents Event = "Job Hook"
DeploymentEvents Event = "Deployment Hook"
SystemHookEvents Event = "System Hook"
objectPush string = "push"
objectTag string = "tag_push"
objectMergeRequest string = "merge_request"
objectBuild string = "build"
eventProjectCreate string = "project_create"
eventProjectDestroy string = "project_destroy"
eventProjectRename string = "project_rename"
eventProjectTransfer string = "project_transfer"
eventProjectUpdate string = "project_update"
eventUserAddToTeam string = "user_add_to_team"
eventUserRemoveFromTeam string = "user_remove_from_team"
eventUserUpdateForTeam string = "user_update_for_team"
eventUserCreate string = "user_create"
eventUserDestroy string = "user_destroy"
eventUserFailedLogin string = "user_failed_login"
eventUserRename string = "user_rename"
eventKeyCreate string = "key_create"
eventKeyDestroy string = "key_destroy"
eventGroupCreate string = "group_create"
eventGroupDestroy string = "group_destroy"
eventGroupRename string = "group_rename"
eventUserAddToGroup string = "user_add_to_group"
eventUserRemoveFromGroup string = "user_remove_from_group"
eventUserUpdateForGroup string = "user_update_for_group"
)

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

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

gitLabEvent := Event(event)

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module github.com/go-playground/webhooks/v6

go 1.15
go 1.17

require (
github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355
github.com/stretchr/testify v1.6.1
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
5 changes: 2 additions & 3 deletions gogs/gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"

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

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

payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil || len(payload) == 0 {
return nil, ErrParsingPayload
}
Expand Down

0 comments on commit 1bc47bb

Please sign in to comment.