forked from TrueCloudLab/lego
chore: update linter (#1708)
This commit is contained in:
parent
be0c6c743d
commit
d99c75a08d
16 changed files with 33 additions and 37 deletions
2
.github/workflows/pr.yml
vendored
2
.github/workflows/pr.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: 1.19
|
||||
GOLANGCI_LINT_VERSION: v1.48.0
|
||||
GOLANGCI_LINT_VERSION: v1.49.0
|
||||
HUGO_VERSION: 0.54.0
|
||||
CGO_ENABLED: 0
|
||||
LEGO_E2E_TESTS: CI
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[run]
|
||||
deadline = "5m"
|
||||
timeout = "5m"
|
||||
skip-files = []
|
||||
|
||||
[linters-settings]
|
||||
|
@ -53,13 +53,16 @@
|
|||
[linters]
|
||||
enable-all = true
|
||||
disable = [
|
||||
"deadcode", # deprecated
|
||||
"exhaustivestruct", # deprecated
|
||||
"golint", # deprecated
|
||||
"ifshort", # deprecated
|
||||
"interfacer", # deprecated
|
||||
"maligned", # deprecated
|
||||
"scopelint", # deprecated
|
||||
"golint", # deprecated
|
||||
"nosnakecase", # deprecated
|
||||
"ifshort", # deprecated
|
||||
"exhaustivestruct", # deprecated
|
||||
"scopelint", # deprecated
|
||||
"structcheck", # deprecated
|
||||
"varcheck", # deprecated
|
||||
"cyclop", # duplicate of gocyclo
|
||||
"sqlclosecheck", # not relevant (SQL)
|
||||
"rowserrcheck", # not relevant (SQL)
|
||||
|
@ -102,7 +105,8 @@
|
|||
exclude = [
|
||||
"Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked",
|
||||
"exported (type|method|function) (.+) should have comment or be unexported",
|
||||
"ST1000: at least one file in a package should have a package comment"
|
||||
"ST1000: at least one file in a package should have a package comment",
|
||||
"package-comments: should have a package comment",
|
||||
]
|
||||
[[issues.exclude-rules]]
|
||||
path = "(.+)_test.go"
|
||||
|
@ -197,12 +201,3 @@
|
|||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/sakuracloud/client.go"
|
||||
text = "mu is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/tencentcloud/client.go"
|
||||
text = "RESOURCENOTFOUND_NODATAOFRECORD contains underscore."
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/ibmcloud/internal/wrapper.go"
|
||||
text = "Dns_Domain(_ResourceRecord)? contains underscore."
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/rfc2136/"
|
||||
text = "RR_Header contains underscore."
|
||||
|
|
|
@ -230,7 +230,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, readError(req, resp)
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ func (c *Client) doRequest(method string, uri *url.URL) (json.RawMessage, error)
|
|||
return nil, errors.New(toUnreadableBodyMessage(req, content))
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("invalid code (%d), error: %s", resp.StatusCode, content)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ func (d *DNSProvider) removeTxtRecord(domain string, recordID int) error {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return readError(req, resp)
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ func (d *DNSProvider) addTxtRecord(fqdn, value string) (*txtRecordResponse, erro
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, readError(req, resp)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/go-acme/lego/v4/log"
|
||||
|
@ -49,7 +50,7 @@ func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 500 {
|
||||
if resp.StatusCode >= http.StatusInternalServerError {
|
||||
return nil, fmt.Errorf("API request failed with HTTP status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
@ -131,9 +131,9 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, fmt.Errorf("API request failed with HTTP status code %d: %s", resp.StatusCode, dynRes.Messages)
|
||||
} else if resp.StatusCode == 307 {
|
||||
} else if resp.StatusCode == http.StatusTemporaryRedirect {
|
||||
// TODO add support for HTTP 307 response and long running jobs
|
||||
return nil, errors.New("API request returned HTTP 307. This is currently unsupported")
|
||||
}
|
||||
|
|
|
@ -163,11 +163,11 @@ func (d *DNSProvider) do(req *http.Request, v interface{}) error {
|
|||
}
|
||||
|
||||
func checkResponse(resp *http.Response) error {
|
||||
if resp.StatusCode == 404 && resp.Request.Method == http.MethodGet {
|
||||
if resp.StatusCode == http.StatusNotFound && resp.Request.Method == http.MethodGet {
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
data, err := readBody(resp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%d [%s] request failed: %w", resp.StatusCode, http.StatusText(resp.StatusCode), err)
|
||||
|
|
|
@ -80,7 +80,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ func (c *Client) postRequest(cmd string, data url.Values) (*Response, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("HTTP error %d [%s]: %v", resp.StatusCode, http.StatusText(resp.StatusCode), string(body))
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ func (d *DNSProvider) doRequest(domain, value, cmd string) error {
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
var content []byte
|
||||
content, err = io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
|
|
@ -169,7 +169,7 @@ func (d *DNSProvider) createTXTRecord(zone, leaf, value string) error {
|
|||
return fmt.Errorf("createTXTRecord: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("createTXTRecord: error in API: %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ func (d *DNSProvider) removeTXTRecord(zone, leaf, value string) error {
|
|||
return fmt.Errorf("removeTXTRecord: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("removeTXTRecord: error in API: %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ func (d *DNSProvider) do(req *http.Request, out interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
var body []byte
|
||||
body, err = readBody(resp)
|
||||
if err != nil {
|
||||
|
|
|
@ -132,7 +132,7 @@ func (d *DNSProvider) loginRequest() error {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return fmt.Errorf("OTC API request failed with HTTP status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ func (c *Client) RemoveRecord(zone string, recordID int) error {
|
|||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return readError(req, resp)
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ func (c *Client) CreateRecord(zone string, record Record) (*CreateRecordResponse
|
|||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return nil, readError(req, resp)
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ func (c *Client) DeleteRecord(zone string, recordID string) error {
|
|||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return readError(req, resp)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue