gitsources: fix linter errors
Fix errors reported by default golangci-lint linters
This commit is contained in:
parent
f80cb15cd6
commit
8ef3c1d9b3
|
@ -16,7 +16,6 @@ package agolagit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -114,18 +113,6 @@ func (c *Client) getResponse(method, path string, query url.Values, header http.
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) getParsedResponse(method, path string, query url.Values, header http.Header, ibody io.Reader, obj interface{}) (*http.Response, error) {
|
|
||||||
resp, err := c.getResponse(method, path, query, header, ibody)
|
|
||||||
if err != nil {
|
|
||||||
return resp, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
d := json.NewDecoder(resp.Body)
|
|
||||||
|
|
||||||
return resp, d.Decode(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetUserInfo() (*gitsource.UserInfo, error) {
|
func (c *Client) GetUserInfo() (*gitsource.UserInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,9 @@ func (c *Client) ParseWebhook(r *http.Request, secret string) (*types.WebhookDat
|
||||||
return nil, errors.Errorf("wrong webhook signature")
|
return nil, errors.Errorf("wrong webhook signature")
|
||||||
}
|
}
|
||||||
h := hmac.New(sha256.New, []byte(secret))
|
h := hmac.New(sha256.New, []byte(secret))
|
||||||
h.Write(data)
|
if _, err := h.Write(data); err != nil {
|
||||||
|
return nil, errors.Errorf("failed to calculate webhook signature")
|
||||||
|
}
|
||||||
cs := h.Sum(nil)
|
cs := h.Sum(nil)
|
||||||
if !hmac.Equal(cs, ds) {
|
if !hmac.Equal(cs, ds) {
|
||||||
return nil, errors.Errorf("wrong webhook signature")
|
return nil, errors.Errorf("wrong webhook signature")
|
||||||
|
|
|
@ -28,9 +28,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
hookPush = "push"
|
|
||||||
hookPullRequest = "pull_request"
|
|
||||||
|
|
||||||
prStateOpen = "open"
|
prStateOpen = "open"
|
||||||
|
|
||||||
prActionOpen = "opened"
|
prActionOpen = "opened"
|
||||||
|
|
|
@ -90,7 +90,9 @@ func New(opts Opts) (*Client, error) {
|
||||||
}
|
}
|
||||||
httpClient := &http.Client{Transport: transport}
|
httpClient := &http.Client{Transport: transport}
|
||||||
client := gitlab.NewOAuthClient(httpClient, opts.Token)
|
client := gitlab.NewOAuthClient(httpClient, opts.Token)
|
||||||
client.SetBaseURL(opts.APIURL)
|
if err := client.SetBaseURL(opts.APIURL); err != nil {
|
||||||
|
return nil, errors.Errorf("failed to set gitlab client base url: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
client: client,
|
client: client,
|
||||||
|
@ -303,10 +305,6 @@ func (c *Client) GetRef(repopath, ref string) (*gitsource.Ref, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &gitsource.Ref{
|
return &gitsource.Ref{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
CommitSHA: remoteBranch.Commit.ID,
|
CommitSHA: remoteBranch.Commit.ID,
|
||||||
|
@ -319,10 +317,6 @@ func (c *Client) GetRef(repopath, ref string) (*gitsource.Ref, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &gitsource.Ref{
|
return &gitsource.Ref{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
CommitSHA: remoteTag.Commit.ID,
|
CommitSHA: remoteTag.Commit.ID,
|
||||||
|
|
|
@ -35,11 +35,6 @@ const (
|
||||||
hookPush = "Push Hook"
|
hookPush = "Push Hook"
|
||||||
hookTagPush = "Tag Push Hook"
|
hookTagPush = "Tag Push Hook"
|
||||||
hookPullRequest = "Merge Request Hook"
|
hookPullRequest = "Merge Request Hook"
|
||||||
|
|
||||||
prStateOpen = "open"
|
|
||||||
|
|
||||||
prActionOpen = "opened"
|
|
||||||
prActionSync = "synchronized"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) ParseWebhook(r *http.Request, secret string) (*types.WebhookData, error) {
|
func (c *Client) ParseWebhook(r *http.Request, secret string) (*types.WebhookData, error) {
|
||||||
|
|
Loading…
Reference in New Issue