From 6b00497f3483c93daa198574ed47c10a038635ce Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 10 Jul 2020 01:48:18 +0200 Subject: [PATCH] chore: update linter. (#1214) --- .golangci.toml | 3 ++- acme/api/account.go | 2 +- acme/api/api.go | 2 +- acme/api/service.go | 2 +- certificate/certificates.go | 2 +- challenge/dns01/dns_challenge.go | 2 +- challenge/dns01/nameserver_test.go | 2 +- challenge/http01/http_challenge_test.go | 2 +- challenge/resolver/prober_mock_test.go | 2 ++ cmd/cmd_renew.go | 2 +- cmd/lego/main.go | 4 +-- cmd/setup.go | 4 +-- internal/dnsdocs/generator.go | 2 +- internal/release.go | 6 ++--- platform/config/env/env.go | 2 +- platform/config/env/env_test.go | 10 +++---- providers/dns/acmedns/acmedns.go | 2 +- providers/dns/bindman/bindman_test.go | 1 + providers/dns/clouddns/internal/client.go | 2 +- providers/dns/cloudns/internal/client.go | 4 +-- providers/dns/cloudxns/internal/client.go | 2 +- providers/dns/constellix/constellix.go | 2 +- providers/dns/desec/internal/client.go | 6 ++--- providers/dns/designate/designate.go | 2 +- providers/dns/dnsmadeeasy/internal/client.go | 4 +-- providers/dns/dynu/internal/client.go | 4 +-- providers/dns/dynu/internal/client_test.go | 27 ++++++++++--------- providers/dns/gandi/client.go | 18 ++++++++----- providers/dns/gandi/gandi_test.go | 2 +- providers/dns/gandiv5/client.go | 4 +-- providers/dns/gandiv5/gandiv5_test.go | 2 +- providers/dns/glesys/client.go | 4 +-- providers/dns/godaddy/client.go | 4 +-- providers/dns/hostingde/client.go | 2 +- providers/dns/internal/rimuhosting/client.go | 6 ++--- .../dns/internal/rimuhosting/client_test.go | 15 ++++++++--- providers/dns/inwx/inwx.go | 2 +- providers/dns/joker/client_test.go | 2 +- providers/dns/lightsail/lightsail.go | 2 +- providers/dns/mydnsjp/client.go | 4 +-- providers/dns/mythicbeasts/client.go | 4 +-- providers/dns/netcup/internal/client.go | 4 +-- providers/dns/netlify/internal/client.go | 2 +- providers/dns/nifcloud/internal/client.go | 2 +- providers/dns/otc/client.go | 2 +- providers/dns/pdns/client.go | 2 +- providers/dns/regru/internal/client.go | 6 ++--- providers/dns/rfc2136/rfc2136_test.go | 5 ++-- providers/dns/route53/route53.go | 2 +- providers/dns/scaleway/scaleway_test.go | 6 ++--- providers/dns/transip/transip_test.go | 4 +-- providers/dns/versio/client.go | 2 +- providers/dns/yandex/internal/client.go | 1 - providers/dns/yandex/yandex.go | 1 + providers/http/webroot/webroot.go | 4 +-- providers/http/webroot/webroot_test.go | 2 +- 56 files changed, 119 insertions(+), 102 deletions(-) diff --git a/.golangci.toml b/.golangci.toml index 732e95f7..c03ee42d 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -37,6 +37,7 @@ "testpackage", # not relevant "nestif", # too many false-positive "goerr113", # not relevant + "noctx", ] [issues] @@ -49,7 +50,7 @@ ] [[issues.exclude-rules]] path = "(.+)_test.go" - linters = ["funlen"] + linters = ["funlen", "goconst"] [[issues.exclude-rules]] path = "providers/dns/dns_providers.go" linters = ["gocyclo"] diff --git a/acme/api/account.go b/acme/api/account.go index e7c19f1c..5d658552 100644 --- a/acme/api/account.go +++ b/acme/api/account.go @@ -28,7 +28,7 @@ func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) { } // NewEAB Creates a new account with an External Account Binding. -func (a *AccountService) NewEAB(accMsg acme.Account, kid string, hmacEncoded string) (acme.ExtendedAccount, error) { +func (a *AccountService) NewEAB(accMsg acme.Account, kid, hmacEncoded string) (acme.ExtendedAccount, error) { hmac, err := base64.RawURLEncoding.DecodeString(hmacEncoded) if err != nil { return acme.ExtendedAccount{}, fmt.Errorf("acme: could not decode hmac key: %w", err) diff --git a/acme/api/api.go b/acme/api/api.go index 29b91536..34f4969b 100644 --- a/acme/api/api.go +++ b/acme/api/api.go @@ -35,7 +35,7 @@ type Core struct { } // New Creates a new Core. -func New(httpClient *http.Client, userAgent string, caDirURL, kid string, privateKey crypto.PrivateKey) (*Core, error) { +func New(httpClient *http.Client, userAgent, caDirURL, kid string, privateKey crypto.PrivateKey) (*Core, error) { doer := sender.NewDoer(httpClient, userAgent) dir, err := getDirectory(doer, caDirURL) diff --git a/acme/api/service.go b/acme/api/service.go index d8bee4c7..0644ccad 100644 --- a/acme/api/service.go +++ b/acme/api/service.go @@ -11,7 +11,7 @@ type service struct { // getLink get a rel into the Link header. func getLink(header http.Header, rel string) string { - var linkExpr = regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`) + linkExpr := regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`) for _, link := range header["Link"] { for _, m := range linkExpr.FindAllStringSubmatch(link, -1) { diff --git a/certificate/certificates.go b/certificate/certificates.go index 43145bfe..da79fc90 100644 --- a/certificate/certificates.go +++ b/certificate/certificates.go @@ -232,7 +232,7 @@ func (c *Certifier) getForOrder(domains []string, order acme.ExtendedOrder, bund return c.getForCSR(domains, order, bundle, csr, certcrypto.PEMEncode(privateKey)) } -func (c *Certifier) getForCSR(domains []string, order acme.ExtendedOrder, bundle bool, csr []byte, privateKeyPem []byte) (*Resource, error) { +func (c *Certifier) getForCSR(domains []string, order acme.ExtendedOrder, bundle bool, csr, privateKeyPem []byte) (*Resource, error) { respOrder, err := c.core.Orders.UpdateForCSR(order.Finalize, csr) if err != nil { return nil, err diff --git a/challenge/dns01/dns_challenge.go b/challenge/dns01/dns_challenge.go index 83d23dfc..da468c7d 100644 --- a/challenge/dns01/dns_challenge.go +++ b/challenge/dns01/dns_challenge.go @@ -172,7 +172,7 @@ type sequential interface { } // GetRecord returns a DNS record which will fulfill the `dns-01` challenge. -func GetRecord(domain, keyAuth string) (fqdn string, value string) { +func GetRecord(domain, keyAuth string) (fqdn, value string) { keyAuthShaBytes := sha256.Sum256([]byte(keyAuth)) // base64URL encoding without padding value = base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size]) diff --git a/challenge/dns01/nameserver_test.go b/challenge/dns01/nameserver_test.go index 6d36635d..ac0ebd30 100644 --- a/challenge/dns01/nameserver_test.go +++ b/challenge/dns01/nameserver_test.go @@ -169,7 +169,7 @@ func TestFindPrimayNsByFqdnCustom(t *testing.T) { } func TestResolveConfServers(t *testing.T) { - var testCases = []struct { + testCases := []struct { fixture string expected []string defaults []string diff --git a/challenge/http01/http_challenge_test.go b/challenge/http01/http_challenge_test.go index 38e1bd7f..2fd51b90 100644 --- a/challenge/http01/http_challenge_test.go +++ b/challenge/http01/http_challenge_test.go @@ -126,7 +126,7 @@ func TestChallengeWithProxy(t *testing.T) { nook = "example.com" ) - var testCases = []struct { + testCases := []struct { name string header *testProxyHeader extra *testProxyHeader diff --git a/challenge/resolver/prober_mock_test.go b/challenge/resolver/prober_mock_test.go index 143652d6..9f604069 100644 --- a/challenge/resolver/prober_mock_test.go +++ b/challenge/resolver/prober_mock_test.go @@ -16,9 +16,11 @@ type preSolverMock struct { func (s *preSolverMock) PreSolve(authorization acme.Authorization) error { return s.preSolve[authorization.Identifier.Value] } + func (s *preSolverMock) Solve(authorization acme.Authorization) error { return s.solve[authorization.Identifier.Value] } + func (s *preSolverMock) CleanUp(authorization acme.Authorization) error { return s.cleanUp[authorization.Identifier.Value] } diff --git a/cmd/cmd_renew.go b/cmd/cmd_renew.go index 72cd6f6e..ee463226 100644 --- a/cmd/cmd_renew.go +++ b/cmd/cmd_renew.go @@ -199,7 +199,7 @@ func needRenewal(x509Cert *x509.Certificate, domain string, days int) bool { return true } -func merge(prevDomains []string, nextDomains []string) []string { +func merge(prevDomains, nextDomains []string) []string { for _, next := range nextDomains { var found bool for _, prev := range prevDomains { diff --git a/cmd/lego/main.go b/cmd/lego/main.go index 098d15b9..44787430 100644 --- a/cmd/lego/main.go +++ b/cmd/lego/main.go @@ -13,9 +13,7 @@ import ( "github.com/urfave/cli" ) -var ( - version = "dev" -) +var version = "dev" func main() { app := cli.NewApp() diff --git a/cmd/setup.go b/cmd/setup.go index 9b7c87e6..5598cdc5 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -16,7 +16,7 @@ import ( "github.com/urfave/cli" ) -const filePerm os.FileMode = 0600 +const filePerm os.FileMode = 0o600 func setup(ctx *cli.Context, accountsStorage *AccountsStorage) (*Account, *lego.Client) { keyType := getKeyType(ctx) @@ -90,7 +90,7 @@ func getEmail(ctx *cli.Context) string { func createNonExistingFolder(path string) error { if _, err := os.Stat(path); os.IsNotExist(err) { - return os.MkdirAll(path, 0700) + return os.MkdirAll(path, 0o700) } else if err != nil { return err } diff --git a/internal/dnsdocs/generator.go b/internal/dnsdocs/generator.go index e9e537e8..5f8df98b 100644 --- a/internal/dnsdocs/generator.go +++ b/internal/dnsdocs/generator.go @@ -201,7 +201,7 @@ func generateReadMe(models *Providers) error { return errors.New("missing end tag") } - return ioutil.WriteFile(readmePath, buffer.Bytes(), 0666) + return ioutil.WriteFile(readmePath, buffer.Bytes(), 0o666) } func extractTableData(models *Providers) (int, [][]string) { diff --git a/internal/release.go b/internal/release.go index b005e15f..0b386a33 100644 --- a/internal/release.go +++ b/internal/release.go @@ -166,7 +166,7 @@ func readUserAgentFile(filename string) (map[string]string, error) { return v.data, nil } -func writeUserAgentFile(filename string, version string, comment string) error { +func writeUserAgentFile(filename, version, comment string) error { tmpl, err := template.New("ua").Parse(uaTemplate) if err != nil { return err @@ -186,10 +186,10 @@ func writeUserAgentFile(filename string, version string, comment string) error { return err } - return ioutil.WriteFile(filename, source, 0644) + return ioutil.WriteFile(filename, source, 0o644) } -func bumpVersion(userAgent string, mode string) (string, error) { +func bumpVersion(userAgent, mode string) (string, error) { prevVersion := strings.TrimPrefix(userAgent, "xenolf-acme/") allString := regexp.MustCompile(`(\d+)\.(\d+)\.(\d+)`).FindStringSubmatch(prevVersion) diff --git a/platform/config/env/env.go b/platform/config/env/env.go index ac060c6c..73d07e48 100644 --- a/platform/config/env/env.go +++ b/platform/config/env/env.go @@ -118,7 +118,7 @@ func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration // GetOrDefaultString returns the given environment variable value as a string. // Returns the default if the envvar cannot be find. -func GetOrDefaultString(envVar string, defaultValue string) string { +func GetOrDefaultString(envVar, defaultValue string) string { v := GetOrFile(envVar) if len(v) == 0 { return defaultValue diff --git a/platform/config/env/env_test.go b/platform/config/env/env_test.go index c1a188f1..dd938c9c 100644 --- a/platform/config/env/env_test.go +++ b/platform/config/env/env_test.go @@ -186,7 +186,7 @@ func TestGetOrDefaultSecond(t *testing.T) { }, } - var key = "LEGO_ENV_TC" + key := "LEGO_ENV_TC" for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { @@ -220,7 +220,7 @@ func TestGetOrDefaultString(t *testing.T) { }, } - var key = "LEGO_ENV_TC" + key := "LEGO_ENV_TC" for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { @@ -260,7 +260,7 @@ func TestGetOrDefaultBool(t *testing.T) { }, } - var key = "LEGO_ENV_TC" + key := "LEGO_ENV_TC" for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { @@ -313,7 +313,7 @@ func TestGetOrFile_ReadsFiles(t *testing.T) { require.NoError(t, err) defer os.Remove(file.Name()) - err = ioutil.WriteFile(file.Name(), []byte("lego_file\n"), 0644) + err = ioutil.WriteFile(file.Name(), []byte("lego_file\n"), 0o644) require.NoError(t, err) err = os.Setenv(varEnvFileName, file.Name()) @@ -340,7 +340,7 @@ func TestGetOrFile_PrefersEnvVars(t *testing.T) { require.NoError(t, err) defer os.Remove(file.Name()) - err = ioutil.WriteFile(file.Name(), []byte("lego_file"), 0644) + err = ioutil.WriteFile(file.Name(), []byte("lego_file"), 0o644) require.NoError(t, err) err = os.Setenv(varEnvFileName, file.Name()) diff --git a/providers/dns/acmedns/acmedns.go b/providers/dns/acmedns/acmedns.go index 766bd179..5ad9af09 100644 --- a/providers/dns/acmedns/acmedns.go +++ b/providers/dns/acmedns/acmedns.go @@ -49,7 +49,7 @@ func NewDNSProvider() (*DNSProvider, error) { } client := goacmedns.NewClient(values[EnvAPIBase]) - storage := goacmedns.NewFileStorage(values[EnvStoragePath], 0600) + storage := goacmedns.NewFileStorage(values[EnvStoragePath], 0o600) return NewDNSProviderClient(client, storage) } diff --git a/providers/dns/bindman/bindman_test.go b/providers/dns/bindman/bindman_test.go index dea5a427..2342ea3f 100644 --- a/providers/dns/bindman/bindman_test.go +++ b/providers/dns/bindman/bindman_test.go @@ -235,6 +235,7 @@ func (m *MockHTTPClientAPI) Post(url string, data []byte) (*http.Response, []byt func (m *MockHTTPClientAPI) Get(url string) (*http.Response, []byte, error) { return &http.Response{StatusCode: m.Status}, m.Data, m.Error } + func (m *MockHTTPClientAPI) Delete(url string) (*http.Response, []byte, error) { return &http.Response{StatusCode: m.Status}, m.Data, m.Error } diff --git a/providers/dns/clouddns/internal/client.go b/providers/dns/clouddns/internal/client.go index 5010bdb6..43958080 100644 --- a/providers/dns/clouddns/internal/client.go +++ b/providers/dns/clouddns/internal/client.go @@ -29,7 +29,7 @@ type Client struct { } // NewClient returns a Client instance configured to handle CloudDNS API communication. -func NewClient(clientID string, email string, password string, ttl int) *Client { +func NewClient(clientID, email, password string, ttl int) *Client { return &Client{ ClientID: clientID, Email: email, diff --git a/providers/dns/cloudns/internal/client.go b/providers/dns/cloudns/internal/client.go index 9847c497..0b12257d 100644 --- a/providers/dns/cloudns/internal/client.go +++ b/providers/dns/cloudns/internal/client.go @@ -41,7 +41,7 @@ type TXTRecord struct { type TXTRecords map[string]TXTRecord // NewClient creates a ClouDNS client. -func NewClient(authID string, subAuthID string, authPassword string) (*Client, error) { +func NewClient(authID, subAuthID, authPassword string) (*Client, error) { if authID == "" && subAuthID == "" { return nil, errors.New("credentials missing: authID or subAuthID") } @@ -147,7 +147,7 @@ func (c *Client) FindTxtRecord(zoneName, fqdn string) (*TXTRecord, error) { } // AddTxtRecord add a TXT record. -func (c *Client) AddTxtRecord(zoneName string, fqdn, value string, ttl int) error { +func (c *Client) AddTxtRecord(zoneName, fqdn, value string, ttl int) error { host := dns01.UnFqdn(strings.TrimSuffix(dns01.UnFqdn(fqdn), zoneName)) reqURL := *c.BaseURL diff --git a/providers/dns/cloudxns/internal/client.go b/providers/dns/cloudxns/internal/client.go index b13a6521..ec7b4e3c 100644 --- a/providers/dns/cloudxns/internal/client.go +++ b/providers/dns/cloudxns/internal/client.go @@ -44,7 +44,7 @@ type TXTRecord struct { } // NewClient creates a CloudXNS client. -func NewClient(apiKey string, secretKey string) (*Client, error) { +func NewClient(apiKey, secretKey string) (*Client, error) { if apiKey == "" { return nil, errors.New("CloudXNS: credentials missing: apiKey") } diff --git a/providers/dns/constellix/constellix.go b/providers/dns/constellix/constellix.go index 0df36c7d..d0172483 100644 --- a/providers/dns/constellix/constellix.go +++ b/providers/dns/constellix/constellix.go @@ -188,7 +188,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return nil } -func (d *DNSProvider) createRecord(dom internal.Domain, fqdn string, recordName string, value string) error { +func (d *DNSProvider) createRecord(dom internal.Domain, fqdn, recordName, value string) error { request := internal.RecordRequest{ Name: recordName, TTL: d.config.TTL, diff --git a/providers/dns/desec/internal/client.go b/providers/dns/desec/internal/client.go index 97be6fa2..f43ea69e 100644 --- a/providers/dns/desec/internal/client.go +++ b/providers/dns/desec/internal/client.go @@ -31,7 +31,7 @@ func NewClient(token string) *Client { // GetTxtRRSet gets a RRSet. // https://desec.readthedocs.io/en/latest/dns/rrsets.html#retrieving-a-specific-rrset -func (c *Client) GetTxtRRSet(domainName string, subName string) (*RRSet, error) { +func (c *Client) GetTxtRRSet(domainName, subName string) (*RRSet, error) { if subName == "" { subName = "@" } @@ -128,7 +128,7 @@ func (c *Client) AddTxtRRSet(rrSet RRSet) (*RRSet, error) { // UpdateTxtRRSet updates RRSet records. // https://desec.readthedocs.io/en/latest/dns/rrsets.html#modifying-an-rrset -func (c *Client) UpdateTxtRRSet(domainName string, subName string, records []string) (*RRSet, error) { +func (c *Client) UpdateTxtRRSet(domainName, subName string, records []string) (*RRSet, error) { if subName == "" { subName = "@" } @@ -181,7 +181,7 @@ func (c *Client) UpdateTxtRRSet(domainName string, subName string, records []str // DeleteTxtRRSet deletes a RRset. // https://desec.readthedocs.io/en/latest/dns/rrsets.html#deleting-an-rrset -func (c *Client) DeleteTxtRRSet(domainName string, subName string) error { +func (c *Client) DeleteTxtRRSet(domainName, subName string) error { if subName == "" { subName = "@" } diff --git a/providers/dns/designate/designate.go b/providers/dns/designate/designate.go index b019e02b..8652f6bd 100644 --- a/providers/dns/designate/designate.go +++ b/providers/dns/designate/designate.go @@ -247,7 +247,7 @@ func (d *DNSProvider) getZoneID(wanted string) (string, error) { return "", fmt.Errorf("zone id not found for %s", wanted) } -func (d *DNSProvider) getRecord(zoneID string, wanted string) (*recordsets.RecordSet, error) { +func (d *DNSProvider) getRecord(zoneID, wanted string) (*recordsets.RecordSet, error) { allPages, err := recordsets.ListByZone(d.client, zoneID, nil).AllPages() if err != nil { return nil, err diff --git a/providers/dns/dnsmadeeasy/internal/client.go b/providers/dns/dnsmadeeasy/internal/client.go index 1fdb1606..c0960acd 100644 --- a/providers/dns/dnsmadeeasy/internal/client.go +++ b/providers/dns/dnsmadeeasy/internal/client.go @@ -42,7 +42,7 @@ type Client struct { } // NewClient creates a DNSMadeEasy client. -func NewClient(apiKey string, apiSecret string) (*Client, error) { +func NewClient(apiKey, apiSecret string) (*Client, error) { if apiKey == "" { return nil, errors.New("credentials missing: API key") } @@ -163,7 +163,7 @@ func (c *Client) sendRequest(method, resource string, payload interface{}) (*htt return resp, nil } -func computeHMAC(message string, secret string) (string, error) { +func computeHMAC(message, secret string) (string, error) { key := []byte(secret) h := hmac.New(sha1.New, key) _, err := h.Write([]byte(message)) diff --git a/providers/dns/dynu/internal/client.go b/providers/dns/dynu/internal/client.go index 0b714e73..2da5824c 100644 --- a/providers/dns/dynu/internal/client.go +++ b/providers/dns/dynu/internal/client.go @@ -33,7 +33,7 @@ func NewClient() *Client { } // GetRecords Get DNS records based on a hostname and resource record type. -func (c Client) GetRecords(hostname string, recordType string) ([]DNSRecord, error) { +func (c Client) GetRecords(hostname, recordType string) ([]DNSRecord, error) { endpoint, err := c.createEndpoint("dns", "record", hostname) if err != nil { return nil, err @@ -82,7 +82,7 @@ func (c Client) AddNewRecord(domainID int64, record DNSRecord) error { } // DeleteRecord Remove a DNS record from DNS service. -func (c Client) DeleteRecord(domainID int64, recordID int64) error { +func (c Client) DeleteRecord(domainID, recordID int64) error { endpoint, err := c.createEndpoint("dns", strconv.FormatInt(domainID, 10), "record", strconv.FormatInt(recordID, 10)) if err != nil { return err diff --git a/providers/dns/dynu/internal/client_test.go b/providers/dns/dynu/internal/client_test.go index 517dcc2a..cf397b24 100644 --- a/providers/dns/dynu/internal/client_test.go +++ b/providers/dns/dynu/internal/client_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func setupTest(method string, pattern string, status int, file string) *Client { +func setupTest(method, pattern string, status int, file string) *Client { mux := http.NewServeMux() server := httptest.NewServer(mux) @@ -126,18 +126,19 @@ func TestGetRecords(t *testing.T) { status: http.StatusOK, file: "./fixtures/get_records.json", expected: expected{ - records: []DNSRecord{{ - ID: 6041417, - Type: "TXT", - DomainID: 9007481, - DomainName: "lego.freeddns.org", - NodeName: "_acme-challenge", - Hostname: "_acme-challenge.lego.freeddns.org", - State: true, - Content: `_acme-challenge.lego.freeddns.org. 300 IN TXT "txt_txt_txt_txt_txt_txt_txt"`, - TextData: "txt_txt_txt_txt_txt_txt_txt", - TTL: 300, - }, + records: []DNSRecord{ + { + ID: 6041417, + Type: "TXT", + DomainID: 9007481, + DomainName: "lego.freeddns.org", + NodeName: "_acme-challenge", + Hostname: "_acme-challenge.lego.freeddns.org", + State: true, + Content: `_acme-challenge.lego.freeddns.org. 300 IN TXT "txt_txt_txt_txt_txt_txt_txt"`, + TextData: "txt_txt_txt_txt_txt_txt_txt", + TTL: 300, + }, { ID: 6041422, Type: "TXT", diff --git a/providers/dns/gandi/client.go b/providers/dns/gandi/client.go index 67af221d..f9f30f67 100644 --- a/providers/dns/gandi/client.go +++ b/providers/dns/gandi/client.go @@ -28,14 +28,17 @@ type paramInt struct { type structMember interface { structMember() } + type structMemberString struct { Name string `xml:"name"` Value string `xml:"value>string"` } + type structMemberInt struct { Name string `xml:"name"` Value int `xml:"value>int"` } + type paramStruct struct { XMLName xml.Name `xml:"param"` StructMembers []structMember `xml:"value>struct>member"` @@ -120,7 +123,8 @@ func (d *DNSProvider) rpcCall(call *methodCall, resp response) error { } if resp.faultCode() != 0 { return rpcError{ - faultCode: resp.faultCode(), faultString: resp.faultString()} + faultCode: resp.faultCode(), faultString: resp.faultString(), + } } return nil } @@ -166,7 +170,8 @@ func (d *DNSProvider) cloneZone(zoneID int, name string) (int, error) { structMemberString{ Name: "name", Value: name, - }}, + }, + }, }, }, }, resp) @@ -206,7 +211,7 @@ func (d *DNSProvider) newZoneVersion(zoneID int) (int, error) { return resp.Value, nil } -func (d *DNSProvider) addTXTRecord(zoneID int, version int, name string, value string, ttl int) error { +func (d *DNSProvider) addTXTRecord(zoneID, version int, name, value string, ttl int) error { resp := &responseStruct{} err := d.rpcCall(&methodCall{ MethodName: "domain.zone.record.add", @@ -228,14 +233,15 @@ func (d *DNSProvider) addTXTRecord(zoneID int, version int, name string, value s }, structMemberInt{ Name: "ttl", Value: ttl, - }}, + }, + }, }, }, }, resp) return err } -func (d *DNSProvider) setZoneVersion(zoneID int, version int) error { +func (d *DNSProvider) setZoneVersion(zoneID, version int) error { resp := &responseBool{} err := d.rpcCall(&methodCall{ MethodName: "domain.zone.version.set", @@ -301,7 +307,7 @@ func (d *DNSProvider) deleteZone(zoneID int) error { return nil } -func (d *DNSProvider) httpPost(url string, bodyType string, body io.Reader) ([]byte, error) { +func (d *DNSProvider) httpPost(url, bodyType string, body io.Reader) ([]byte, error) { resp, err := d.config.HTTPClient.Post(url, bodyType, body) if err != nil { return nil, fmt.Errorf("HTTP Post Error: %w", err) diff --git a/providers/dns/gandi/gandi_test.go b/providers/dns/gandi/gandi_test.go index bee51a4c..15a70067 100644 --- a/providers/dns/gandi/gandi_test.go +++ b/providers/dns/gandi/gandi_test.go @@ -101,7 +101,7 @@ func TestDNSProvider(t *testing.T) { // fake RPC server. It was generated by recording a real RPC session // which resulted in the successful issue of a cert, and then // anonymizing the RPC data. - var serverResponses = map[string]string{ + serverResponses := map[string]string{ // Present Request->Response 1 (getZoneID) presentGetZoneIDRequestMock: presentGetZoneIDResponseMock, // Present Request->Response 2 (cloneZone) diff --git a/providers/dns/gandiv5/client.go b/providers/dns/gandiv5/client.go index 7671531c..31b13bdb 100644 --- a/providers/dns/gandiv5/client.go +++ b/providers/dns/gandiv5/client.go @@ -27,7 +27,7 @@ type Record struct { RRSetType string `json:"rrset_type,omitempty"` } -func (d *DNSProvider) addTXTRecord(domain string, name string, value string, ttl int) error { +func (d *DNSProvider) addTXTRecord(domain, name, value string, ttl int) error { // Get exiting values for the TXT records // Needed to create challenges for both wildcard and base name domains txtRecord, err := d.getTXTRecord(domain, name) @@ -80,7 +80,7 @@ func (d *DNSProvider) getTXTRecord(domain, name string) (*Record, error) { return txtRecord, nil } -func (d *DNSProvider) deleteTXTRecord(domain string, name string) error { +func (d *DNSProvider) deleteTXTRecord(domain, name string) error { target := fmt.Sprintf("domains/%s/records/%s/TXT", domain, name) req, err := d.newRequest(http.MethodDelete, target, nil) diff --git a/providers/dns/gandiv5/gandiv5_test.go b/providers/dns/gandiv5/gandiv5_test.go index b076cee0..325a4488 100644 --- a/providers/dns/gandiv5/gandiv5_test.go +++ b/providers/dns/gandiv5/gandiv5_test.go @@ -97,7 +97,7 @@ func TestNewDNSProviderConfig(t *testing.T) { func TestDNSProvider(t *testing.T) { // serverResponses is the JSON Request->Response map used by the // fake JSON server. - var serverResponses = map[string]map[string]string{ + serverResponses := map[string]map[string]string{ http.MethodGet: { ``: `{"rrset_ttl":300,"rrset_values":[],"rrset_name":"_acme-challenge.abc.def","rrset_type":"TXT"}`, }, diff --git a/providers/dns/glesys/client.go b/providers/dns/glesys/client.go index a44d3c45..03c4b978 100644 --- a/providers/dns/glesys/client.go +++ b/providers/dns/glesys/client.go @@ -32,7 +32,7 @@ type responseStruct struct { } `json:"response"` } -func (d *DNSProvider) addTXTRecord(fqdn string, domain string, name string, value string, ttl int) (int, error) { +func (d *DNSProvider) addTXTRecord(fqdn, domain, name, value string, ttl int) (int, error) { response, err := d.sendRequest(http.MethodPost, "addrecord", addRecordRequest{ DomainName: domain, Host: name, @@ -58,7 +58,7 @@ func (d *DNSProvider) deleteTXTRecord(fqdn string, recordid int) error { return err } -func (d *DNSProvider) sendRequest(method string, resource string, payload interface{}) (*responseStruct, error) { +func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) (*responseStruct, error) { url := fmt.Sprintf("%s/%s", defaultBaseURL, resource) body, err := json.Marshal(payload) diff --git a/providers/dns/godaddy/client.go b/providers/dns/godaddy/client.go index 50cdc54e..d30001e8 100644 --- a/providers/dns/godaddy/client.go +++ b/providers/dns/godaddy/client.go @@ -19,7 +19,7 @@ type DNSRecord struct { TTL int `json:"ttl,omitempty"` } -func (d *DNSProvider) getRecords(domainZone string, rType string, recordName string) ([]DNSRecord, error) { +func (d *DNSProvider) getRecords(domainZone, rType, recordName string) ([]DNSRecord, error) { resource := path.Clean(fmt.Sprintf("/v1/domains/%s/records/%s/%s", domainZone, rType, recordName)) resp, err := d.makeRequest(http.MethodGet, resource, nil) @@ -44,7 +44,7 @@ func (d *DNSProvider) getRecords(domainZone string, rType string, recordName str return records, nil } -func (d *DNSProvider) updateTxtRecords(records []DNSRecord, domainZone string, recordName string) error { +func (d *DNSProvider) updateTxtRecords(records []DNSRecord, domainZone, recordName string) error { body, err := json.Marshal(records) if err != nil { return err diff --git a/providers/dns/hostingde/client.go b/providers/dns/hostingde/client.go index 9b7ad0fe..04ed2d4e 100644 --- a/providers/dns/hostingde/client.go +++ b/providers/dns/hostingde/client.go @@ -91,7 +91,7 @@ func (d *DNSProvider) getZone(findRequest ZoneConfigsFindRequest) (*ZoneConfig, return zoneConfig, nil } -func (d *DNSProvider) post(uri string, request interface{}, response interface{}) ([]byte, error) { +func (d *DNSProvider) post(uri string, request, response interface{}) ([]byte, error) { body, err := json.Marshal(request) if err != nil { return nil, err diff --git a/providers/dns/internal/rimuhosting/client.go b/providers/dns/internal/rimuhosting/client.go index 407dc6d9..e71d2e26 100644 --- a/providers/dns/internal/rimuhosting/client.go +++ b/providers/dns/internal/rimuhosting/client.go @@ -105,7 +105,7 @@ func (c Client) toMultiParameters(params []ActionParameter) multiActionParameter return multi } -func (c Client) do(params interface{}, data interface{}) error { +func (c Client) do(params, data interface{}) error { baseURL, err := url.Parse(c.BaseURL) if err != nil { return err @@ -157,7 +157,7 @@ func (c Client) do(params interface{}, data interface{}) error { } // AddRecord helper to create an action to add a TXT record. -func AddRecord(domain string, content string, ttl int) ActionParameter { +func AddRecord(domain, content string, ttl int) ActionParameter { return ActionParameter{ Action: SetAction, Name: domain, @@ -168,7 +168,7 @@ func AddRecord(domain string, content string, ttl int) ActionParameter { } // DeleteRecord helper to create an action to delete a TXT record. -func DeleteRecord(domain string, content string) ActionParameter { +func DeleteRecord(domain, content string) ActionParameter { return ActionParameter{ Action: DeleteAction, Name: domain, diff --git a/providers/dns/internal/rimuhosting/client_test.go b/providers/dns/internal/rimuhosting/client_test.go index d2f57aea..bed718fc 100644 --- a/providers/dns/internal/rimuhosting/client_test.go +++ b/providers/dns/internal/rimuhosting/client_test.go @@ -144,7 +144,8 @@ func TestClient_DoActions(t *testing.T) { TTL: "3600 seconds", Priority: "0", }}, - }}, + }, + }, }, }, }, @@ -182,7 +183,9 @@ func TestClient_DoActions(t *testing.T) { Priority: "0", }, }, - }}}, + }, + }, + }, }, }, { @@ -214,7 +217,9 @@ func TestClient_DoActions(t *testing.T) { Host: "example.org", Type: "TXT", Records: nil, - }}}, + }, + }, + }, }, }, { @@ -241,7 +246,9 @@ func TestClient_DoActions(t *testing.T) { TTL: "3600 seconds", Priority: "0", }}, - }}}, + }, + }, + }, }, }, } diff --git a/providers/dns/inwx/inwx.go b/providers/dns/inwx/inwx.go index 8deb3f55..2d05e1ef 100644 --- a/providers/dns/inwx/inwx.go +++ b/providers/dns/inwx/inwx.go @@ -116,7 +116,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { return fmt.Errorf("inwx: %w", err) } - var request = &goinwx.NameserverRecordRequest{ + request := &goinwx.NameserverRecordRequest{ Domain: dns01.UnFqdn(authZone), Name: dns01.UnFqdn(fqdn), Type: "TXT", diff --git a/providers/dns/joker/client_test.go b/providers/dns/joker/client_test.go index 83d37a26..a1b0786e 100644 --- a/providers/dns/joker/client_test.go +++ b/providers/dns/joker/client_test.go @@ -255,7 +255,7 @@ func TestDNSProvider_logout(t *testing.T) { } func TestDNSProvider_getZone(t *testing.T) { - var testZone = "@ A 0 192.0.2.2 3600" + testZone := "@ A 0 192.0.2.2 3600" testCases := []struct { desc string diff --git a/providers/dns/lightsail/lightsail.go b/providers/dns/lightsail/lightsail.go index f3c8874a..663cd08e 100644 --- a/providers/dns/lightsail/lightsail.go +++ b/providers/dns/lightsail/lightsail.go @@ -150,7 +150,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } -func (d *DNSProvider) newTxtRecord(fqdn string, value string) error { +func (d *DNSProvider) newTxtRecord(fqdn, value string) error { params := &lightsail.CreateDomainEntryInput{ DomainName: aws.String(d.config.DNSZone), DomainEntry: &lightsail.DomainEntry{ diff --git a/providers/dns/mydnsjp/client.go b/providers/dns/mydnsjp/client.go index 66b82e8f..3bb72fae 100644 --- a/providers/dns/mydnsjp/client.go +++ b/providers/dns/mydnsjp/client.go @@ -8,7 +8,7 @@ import ( "strings" ) -func (d *DNSProvider) doRequest(domain, value string, cmd string) error { +func (d *DNSProvider) doRequest(domain, value, cmd string) error { req, err := d.buildRequest(domain, value, cmd) if err != nil { return err @@ -34,7 +34,7 @@ func (d *DNSProvider) doRequest(domain, value string, cmd string) error { return nil } -func (d *DNSProvider) buildRequest(domain, value string, cmd string) (*http.Request, error) { +func (d *DNSProvider) buildRequest(domain, value, cmd string) (*http.Request, error) { params := url.Values{} params.Set("CERTBOT_DOMAIN", domain) params.Set("CERTBOT_VALIDATION", value) diff --git a/providers/dns/mythicbeasts/client.go b/providers/dns/mythicbeasts/client.go index 4d6fc3fd..a9d8e770 100644 --- a/providers/dns/mythicbeasts/client.go +++ b/providers/dns/mythicbeasts/client.go @@ -120,7 +120,7 @@ func (d *DNSProvider) login() error { } // https://www.mythic-beasts.com/support/api/dnsv2#ep-get-zoneszonerecords -func (d *DNSProvider) createTXTRecord(zone string, leaf string, value string) error { +func (d *DNSProvider) createTXTRecord(zone, leaf, value string) error { if d.token == "" { return fmt.Errorf("createTXTRecord: not logged in") } @@ -183,7 +183,7 @@ func (d *DNSProvider) createTXTRecord(zone string, leaf string, value string) er } // https://www.mythic-beasts.com/support/api/dnsv2#ep-delete-zoneszonerecords -func (d *DNSProvider) removeTXTRecord(zone string, leaf string, value string) error { +func (d *DNSProvider) removeTXTRecord(zone, leaf, value string) error { if d.token == "" { return fmt.Errorf("removeTXTRecord: not logged in") } diff --git a/providers/dns/netcup/internal/client.go b/providers/dns/netcup/internal/client.go index f82ee016..720e2759 100644 --- a/providers/dns/netcup/internal/client.go +++ b/providers/dns/netcup/internal/client.go @@ -122,7 +122,7 @@ type Client struct { } // NewClient creates a netcup DNS client. -func NewClient(customerNumber string, apiKey string, apiPassword string) (*Client, error) { +func NewClient(customerNumber, apiKey, apiPassword string) (*Client, error) { if customerNumber == "" || apiKey == "" || apiPassword == "" { return nil, errors.New("credentials missing") } @@ -231,7 +231,7 @@ func (c *Client) GetDNSRecords(hostname, apiSessionID string) ([]DNSRecord, erro // doRequest marshals given body to JSON, send the request to netcup API // and returns body of response. -func (c *Client) doRequest(payload interface{}, responseData interface{}) error { +func (c *Client) doRequest(payload, responseData interface{}) error { body, err := json.Marshal(payload) if err != nil { return err diff --git a/providers/dns/netlify/internal/client.go b/providers/dns/netlify/internal/client.go index 2bb46823..4d409e28 100644 --- a/providers/dns/netlify/internal/client.go +++ b/providers/dns/netlify/internal/client.go @@ -116,7 +116,7 @@ func (c *Client) CreateRecord(zoneID string, record DNSRecord) (*DNSRecord, erro } // RemoveRecord removes a DNS records. -func (c *Client) RemoveRecord(zoneID string, recordID string) error { +func (c *Client) RemoveRecord(zoneID, recordID string) error { endpoint, err := c.createEndpoint("dns_zones", zoneID, "dns_records", recordID) if err != nil { return fmt.Errorf("failed to parse endpoint: %w", err) diff --git a/providers/dns/nifcloud/internal/client.go b/providers/dns/nifcloud/internal/client.go index 9aac1762..e4585661 100644 --- a/providers/dns/nifcloud/internal/client.go +++ b/providers/dns/nifcloud/internal/client.go @@ -88,7 +88,7 @@ type ChangeInfo struct { } // NewClient Creates a new client of NIFCLOUD DNS. -func NewClient(accessKey string, secretKey string) (*Client, error) { +func NewClient(accessKey, secretKey string) (*Client, error) { if len(accessKey) == 0 || len(secretKey) == 0 { return nil, errors.New("credentials missing") } diff --git a/providers/dns/otc/client.go b/providers/dns/otc/client.go index c2e789e3..86e22afe 100644 --- a/providers/dns/otc/client.go +++ b/providers/dns/otc/client.go @@ -193,7 +193,7 @@ func (d *DNSProvider) getZoneID(zone string) (string, error) { return zonesRes.Zones[0].ID, nil } -func (d *DNSProvider) getRecordSetID(zoneID string, fqdn string) (string, error) { +func (d *DNSProvider) getRecordSetID(zoneID, fqdn string) (string, error) { resource := fmt.Sprintf("zones/%s/recordsets?type=TXT&name=%s", zoneID, fqdn) resp, err := d.sendRequest(http.MethodGet, resource, nil) if err != nil { diff --git a/providers/dns/pdns/client.go b/providers/dns/pdns/client.go index 5d804d25..ff47b301 100644 --- a/providers/dns/pdns/client.go +++ b/providers/dns/pdns/client.go @@ -195,7 +195,7 @@ func (d *DNSProvider) sendRequest(method, uri string, body io.Reader) (json.RawM } func (d *DNSProvider) makeRequest(method, uri string, body io.Reader) (*http.Request, error) { - var path = "" + path := "" if d.config.Host.Path != "/" { path = d.config.Host.Path } diff --git a/providers/dns/regru/internal/client.go b/providers/dns/regru/internal/client.go index 7d83ea1a..b6691cd7 100644 --- a/providers/dns/regru/internal/client.go +++ b/providers/dns/regru/internal/client.go @@ -21,7 +21,7 @@ type Client struct { } // NewClient Creates a reg.ru client. -func NewClient(username string, password string) *Client { +func NewClient(username, password string) *Client { return &Client{ username: username, password: password, @@ -32,7 +32,7 @@ func NewClient(username string, password string) *Client { // RemoveTxtRecord removes a TXT record. // https://www.reg.ru/support/help/api2#zone_remove_record -func (c Client) RemoveTxtRecord(domain, subDomain string, content string) error { +func (c Client) RemoveTxtRecord(domain, subDomain, content string) error { request := RemoveRecordRequest{ Username: c.username, Password: c.password, @@ -55,7 +55,7 @@ func (c Client) RemoveTxtRecord(domain, subDomain string, content string) error // AddTXTRecord adds a TXT record. // https://www.reg.ru/support/help/api2#zone_add_txt -func (c Client) AddTXTRecord(domain, subDomain string, content string) error { +func (c Client) AddTXTRecord(domain, subDomain, content string) error { request := AddTxtRequest{ Username: c.username, Password: c.password, diff --git a/providers/dns/rfc2136/rfc2136_test.go b/providers/dns/rfc2136/rfc2136_test.go index bbefbe57..61b6aa4c 100644 --- a/providers/dns/rfc2136/rfc2136_test.go +++ b/providers/dns/rfc2136/rfc2136_test.go @@ -111,7 +111,7 @@ func TestTsigClient(t *testing.T) { } func TestValidUpdatePacket(t *testing.T) { - var reqChan = make(chan *dns.Msg, 10) + reqChan := make(chan *dns.Msg, 10) dns01.ClearFqdnCache() dns.HandleFunc(fakeZone, serverHandlerPassBackRequest(reqChan)) @@ -170,7 +170,8 @@ func runLocalDNSTestServer(tsig bool) (*dns.Server, string, error) { MsgAcceptFunc: func(dh dns.Header) dns.MsgAcceptAction { // bypass defaultMsgAcceptFunc to allow dynamic update (https://github.com/miekg/dns/pull/830) return dns.MsgAccept - }} + }, + } if tsig { server.TsigSecret = map[string]string{fakeTsigKey: fakeTsigSecret} diff --git a/providers/dns/route53/route53.go b/providers/dns/route53/route53.go index dffc0180..15630f5f 100644 --- a/providers/dns/route53/route53.go +++ b/providers/dns/route53/route53.go @@ -231,7 +231,7 @@ func (d *DNSProvider) changeRecord(action, hostedZoneID string, recordSet *route }) } -func (d *DNSProvider) getExistingRecordSets(hostedZoneID string, fqdn string) ([]*route53.ResourceRecord, error) { +func (d *DNSProvider) getExistingRecordSets(hostedZoneID, fqdn string) ([]*route53.ResourceRecord, error) { listInput := &route53.ListResourceRecordSetsInput{ HostedZoneId: aws.String(hostedZoneID), StartRecordName: aws.String(fqdn), diff --git a/providers/dns/scaleway/scaleway_test.go b/providers/dns/scaleway/scaleway_test.go index 87a6a9a1..288f9316 100644 --- a/providers/dns/scaleway/scaleway_test.go +++ b/providers/dns/scaleway/scaleway_test.go @@ -13,7 +13,7 @@ import ( const cleanUpDelay = 2 * time.Second func TestNewDNSProvider(t *testing.T) { - var envTest = tester.NewEnvTest(EnvAPIToken, EnvTTL) + envTest := tester.NewEnvTest(EnvAPIToken, EnvTTL) testCases := []struct { desc string @@ -97,7 +97,7 @@ func TestNewDNSProviderConfig(t *testing.T) { } func TestLivePresent(t *testing.T) { - var envTest = tester.NewEnvTest(EnvAPIToken, EnvTTL) + envTest := tester.NewEnvTest(EnvAPIToken, EnvTTL) if !envTest.IsLiveTest() { t.Skip("skipping live test") @@ -112,7 +112,7 @@ func TestLivePresent(t *testing.T) { } func TestLiveCleanUp(t *testing.T) { - var envTest = tester.NewEnvTest(EnvAPIToken, EnvTTL) + envTest := tester.NewEnvTest(EnvAPIToken, EnvTTL) if !envTest.IsLiveTest() { t.Skip("skipping live test") diff --git a/providers/dns/transip/transip_test.go b/providers/dns/transip/transip_test.go index dc5367b5..95ce193f 100644 --- a/providers/dns/transip/transip_test.go +++ b/providers/dns/transip/transip_test.go @@ -178,7 +178,7 @@ func TestDNSProvider_concurrentGetDNSEntries(t *testing.T) { var wg sync.WaitGroup wg.Add(2) - solve := func(domain1 string, suffix string, timeoutPresent time.Duration, timeoutSolve time.Duration, timeoutCleanup time.Duration) error { + solve := func(domain1, suffix string, timeoutPresent, timeoutSolve, timeoutCleanup time.Duration) error { time.Sleep(timeoutPresent) err := p.Present(domain1, "", "") @@ -234,7 +234,7 @@ func TestDNSProvider_concurrentAddDNSEntry(t *testing.T) { var wg sync.WaitGroup wg.Add(2) - solve := func(domain1 string, timeoutPresent time.Duration, timeoutCleanup time.Duration) error { + solve := func(domain1 string, timeoutPresent, timeoutCleanup time.Duration) error { time.Sleep(timeoutPresent) err := p.Present(domain1, "", "") if err != nil { diff --git a/providers/dns/versio/client.go b/providers/dns/versio/client.go index 7ed749e7..6f70c803 100644 --- a/providers/dns/versio/client.go +++ b/providers/dns/versio/client.go @@ -68,7 +68,7 @@ func (d *DNSProvider) getDNSRecords(domain string) (*dnsRecordsResponse, error) return respData, nil } -func (d *DNSProvider) makeRequest(method string, uri string, body io.Reader) (*http.Request, error) { +func (d *DNSProvider) makeRequest(method, uri string, body io.Reader) (*http.Request, error) { endpoint, err := d.config.BaseURL.Parse(path.Join(d.config.BaseURL.EscapedPath(), uri)) if err != nil { return nil, err diff --git a/providers/dns/yandex/internal/client.go b/providers/dns/yandex/internal/client.go index be8735b0..acf98dc3 100644 --- a/providers/dns/yandex/internal/client.go +++ b/providers/dns/yandex/internal/client.go @@ -81,7 +81,6 @@ func (c *Client) GetRecords(domain string) ([]Record, error) { resp, err := c.get("/list", struct { Domain string `url:"domain"` }{Domain: domain}) - if err != nil { return nil, err } diff --git a/providers/dns/yandex/yandex.go b/providers/dns/yandex/yandex.go index 045020e8..9c95f3b9 100644 --- a/providers/dns/yandex/yandex.go +++ b/providers/dns/yandex/yandex.go @@ -130,6 +130,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { var record *internal.Record for _, rcd := range records { + rcd := rcd if rcd.Type == "TXT" && rcd.SubDomain == subDomain && rcd.Content == value { record = &rcd break diff --git a/providers/http/webroot/webroot.go b/providers/http/webroot/webroot.go index 83e95b85..6831bd1a 100644 --- a/providers/http/webroot/webroot.go +++ b/providers/http/webroot/webroot.go @@ -30,12 +30,12 @@ func (w *HTTPProvider) Present(domain, token, keyAuth string) error { var err error challengeFilePath := filepath.Join(w.path, http01.ChallengePath(token)) - err = os.MkdirAll(filepath.Dir(challengeFilePath), 0755) + err = os.MkdirAll(filepath.Dir(challengeFilePath), 0o755) if err != nil { return fmt.Errorf("could not create required directories in webroot for HTTP challenge: %w", err) } - err = ioutil.WriteFile(challengeFilePath, []byte(keyAuth), 0644) + err = ioutil.WriteFile(challengeFilePath, []byte(keyAuth), 0o644) if err != nil { return fmt.Errorf("could not write file in webroot for HTTP challenge: %w", err) } diff --git a/providers/http/webroot/webroot_test.go b/providers/http/webroot/webroot_test.go index 5fccae37..09f674cb 100644 --- a/providers/http/webroot/webroot_test.go +++ b/providers/http/webroot/webroot_test.go @@ -16,7 +16,7 @@ func TestHTTPProvider(t *testing.T) { keyAuth := "keyAuth" challengeFilePath := webroot + "/.well-known/acme-challenge/" + token - require.NoError(t, os.MkdirAll(webroot+"/.well-known/acme-challenge", 0777)) + require.NoError(t, os.MkdirAll(webroot+"/.well-known/acme-challenge", 0o777)) defer os.RemoveAll(webroot) provider, err := NewHTTPProvider(webroot)