From dc2b19e1b1a455b271716dffbcd1ff85cd3076ee Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 25 Aug 2021 11:44:11 +0200 Subject: [PATCH] chore: update Go (#1469) --- .github/workflows/go-cross.yml | 2 +- .github/workflows/main.yml | 4 ++-- .golangci.toml | 1 + acme/api/certificate.go | 4 ++-- acme/api/internal/sender/sender.go | 5 ++--- acme/api/order_test.go | 6 +++--- certificate/certificates.go | 6 +++--- challenge/http01/http_challenge_test.go | 6 +++--- challenge/resolver/solver_manager_test.go | 6 +++--- cmd/accounts_storage.go | 7 +++---- cmd/certs_storage.go | 5 ++--- cmd/cmd_list.go | 6 +++--- cmd/setup.go | 3 +-- e2e/challenges_test.go | 3 +-- go.mod | 2 +- go.sum | 2 -- internal/dnsdocs/generator.go | 3 +-- internal/release.go | 3 +-- lego/client_config.go | 3 +-- platform/config/env/env.go | 3 +-- platform/config/env/env_test.go | 4 ++-- providers/dns/allinkl/internal/client.go | 10 +++++----- providers/dns/arvancloud/internal/client.go | 7 +++---- providers/dns/auroradns/auroradns_test.go | 4 ++-- providers/dns/autodns/client.go | 5 ++--- providers/dns/azure/azure.go | 4 ++-- providers/dns/bluecat/bluecat.go | 4 ++-- providers/dns/bluecat/client.go | 8 ++++---- providers/dns/checkdomain/client.go | 5 ++--- providers/dns/checkdomain/client_test.go | 4 ++-- providers/dns/clouddns/internal/client.go | 5 ++--- providers/dns/cloudns/internal/client.go | 4 ++-- providers/dns/cloudxns/internal/client.go | 4 ++-- providers/dns/cloudxns/internal/client_test.go | 4 ++-- providers/dns/conoha/internal/client.go | 6 +++--- providers/dns/conoha/internal/client_test.go | 4 ++-- providers/dns/constellix/internal/client.go | 6 +++--- providers/dns/constellix/internal/txtrecords_test.go | 7 +++---- providers/dns/digitalocean/client.go | 5 ++--- providers/dns/digitalocean/digitalocean_test.go | 4 ++-- providers/dns/dnsmadeeasy/internal/client.go | 4 ++-- providers/dns/dode/client.go | 4 ++-- providers/dns/domeneshop/internal/client.go | 4 ++-- providers/dns/dreamhost/client.go | 4 ++-- providers/dns/duckdns/client.go | 4 ++-- providers/dns/dynu/internal/client.go | 3 +-- providers/dns/easydns/client.go | 4 ++-- providers/dns/easydns/easydns_test.go | 4 ++-- providers/dns/gandi/client.go | 3 +-- providers/dns/gandi/gandi_test.go | 3 +-- providers/dns/gandiv5/client.go | 4 ++-- providers/dns/gandiv5/gandiv5_test.go | 4 ++-- providers/dns/gcloud/googlecloud.go | 4 ++-- providers/dns/gcore/internal/client.go | 4 ++-- providers/dns/godaddy/client.go | 5 ++--- providers/dns/hetzner/internal/client.go | 5 ++--- providers/dns/hostingde/client.go | 4 ++-- providers/dns/hosttech/internal/client.go | 6 +++--- providers/dns/httpreq/httpreq.go | 4 ++-- providers/dns/hurricane/internal/client.go | 4 ++-- providers/dns/hyperone/internal/client.go | 5 ++--- providers/dns/hyperone/internal/client_test.go | 3 +-- providers/dns/infomaniak/internal/client.go | 3 +-- providers/dns/infomaniak/internal/client_test.go | 4 ++-- providers/dns/internal/rimuhosting/client.go | 4 ++-- providers/dns/internal/selectel/client.go | 6 +++--- providers/dns/internetbs/internal/client.go | 9 +++++---- providers/dns/ionos/internal/client.go | 3 +-- providers/dns/joker/internal/dmapi/client.go | 4 ++-- providers/dns/joker/internal/svc/client.go | 4 ++-- providers/dns/joker/internal/svc/client_test.go | 6 +++--- providers/dns/liquidweb/liquidweb_test.go | 4 ++-- providers/dns/loopia/internal/client.go | 3 +-- providers/dns/loopia/internal/client_test.go | 8 ++++---- providers/dns/luadns/internal/client.go | 7 +++---- providers/dns/mydnsjp/client.go | 4 ++-- providers/dns/mythicbeasts/client.go | 8 ++++---- providers/dns/namecheap/client.go | 4 ++-- providers/dns/namecheap/namecheap.go | 4 ++-- providers/dns/netcup/internal/client.go | 6 +++--- providers/dns/netcup/internal/client_test.go | 10 +++++----- providers/dns/netlify/internal/client.go | 8 ++++---- providers/dns/oraclecloud/configprovider.go | 3 +-- providers/dns/otc/client.go | 3 +-- providers/dns/otc/mock_test.go | 4 ++-- providers/dns/rackspace/rackspace_test.go | 6 +++--- providers/dns/regru/internal/client.go | 4 ++-- providers/dns/servercow/internal/client.go | 8 ++++---- providers/dns/servercow/internal/client_test.go | 7 +++---- providers/dns/sonic/internal/client.go | 4 ++-- providers/dns/stackpath/client.go | 4 ++-- providers/dns/versio/client.go | 5 ++--- providers/dns/vinyldns/mock_test.go | 4 ++-- providers/dns/wedos/internal/client.go | 4 ++-- providers/dns/wedos/internal/client_test.go | 4 ++-- providers/dns/zoneee/client.go | 5 ++--- providers/http/webroot/webroot.go | 3 +-- providers/http/webroot/webroot_test.go | 3 +-- 98 files changed, 210 insertions(+), 243 deletions(-) diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml index b81a80d5..17b45eaf 100644 --- a/.github/workflows/go-cross.yml +++ b/.github/workflows/go-cross.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - go-version: [ 1.15, 1.16, 1.x ] + go-version: [ 1.16, 1.17, 1.x ] os: [ubuntu-latest, macos-latest, windows-latest] steps: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f33d4e91..7b328408 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,8 +14,8 @@ jobs: name: Main Process runs-on: ubuntu-latest env: - GO_VERSION: 1.16 - GOLANGCI_LINT_VERSION: v1.41.1 + GO_VERSION: 1.17 + GOLANGCI_LINT_VERSION: v1.42.0 HUGO_VERSION: 0.54.0 SEIHON_VERSION: v0.8.3 CGO_ENABLED: 0 diff --git a/.golangci.toml b/.golangci.toml index 60cdd2da..2d984281 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -73,6 +73,7 @@ "noctx", "forcetypeassert", "tagliatelle", + "errname", ] [issues] diff --git a/acme/api/certificate.go b/acme/api/certificate.go index 8923644b..70bddaf3 100644 --- a/acme/api/certificate.go +++ b/acme/api/certificate.go @@ -4,7 +4,7 @@ import ( "crypto/x509" "encoding/pem" "errors" - "io/ioutil" + "io" "net/http" "github.com/go-acme/lego/v4/acme" @@ -71,7 +71,7 @@ func (c *CertificateService) get(certURL string, bundle bool) (*acme.RawCertific return nil, nil, err } - data, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) + data, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) if err != nil { return nil, resp.Header, err } diff --git a/acme/api/internal/sender/sender.go b/acme/api/internal/sender/sender.go index fec2a332..9b5c5041 100644 --- a/acme/api/internal/sender/sender.go +++ b/acme/api/internal/sender/sender.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "runtime" "strings" @@ -96,7 +95,7 @@ func (d *Doer) do(req *http.Request, response interface{}) (*http.Response, erro } if response != nil { - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return resp, err } @@ -120,7 +119,7 @@ func (d *Doer) formatUserAgent() string { func checkError(req *http.Request, resp *http.Response) error { if resp.StatusCode >= http.StatusBadRequest { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("%d :: %s :: %s :: %w", resp.StatusCode, req.Method, req.URL, err) } diff --git a/acme/api/order_test.go b/acme/api/order_test.go index 49d3fe34..13211798 100644 --- a/acme/api/order_test.go +++ b/acme/api/order_test.go @@ -4,7 +4,7 @@ import ( "crypto/rand" "crypto/rsa" "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -12,7 +12,7 @@ import ( "github.com/go-acme/lego/v4/platform/tester" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - jose "gopkg.in/square/go-jose.v2" + "gopkg.in/square/go-jose.v2" ) func TestOrderService_New(t *testing.T) { @@ -67,7 +67,7 @@ func TestOrderService_New(t *testing.T) { } func readSignedBody(r *http.Request, privateKey *rsa.PrivateKey) ([]byte, error) { - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return nil, err } diff --git a/certificate/certificates.go b/certificate/certificates.go index a1306802..596f9512 100644 --- a/certificate/certificates.go +++ b/certificate/certificates.go @@ -7,7 +7,7 @@ import ( "encoding/base64" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strings" "time" @@ -465,7 +465,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) { } defer resp.Body.Close() - issuerBytes, errC := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) + issuerBytes, errC := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) if errC != nil { return nil, nil, errC } @@ -494,7 +494,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) { } defer resp.Body.Close() - ocspResBytes, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) + ocspResBytes, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) if err != nil { return nil, nil, err } diff --git a/challenge/http01/http_challenge_test.go b/challenge/http01/http_challenge_test.go index 81b500e0..62bf3abc 100644 --- a/challenge/http01/http_challenge_test.go +++ b/challenge/http01/http_challenge_test.go @@ -4,7 +4,7 @@ import ( "crypto/rand" "crypto/rsa" "fmt" - "io/ioutil" + "io" "net/http" "net/textproto" "testing" @@ -36,7 +36,7 @@ func TestChallenge(t *testing.T) { t.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -283,7 +283,7 @@ func testServeWithProxy(t *testing.T, header, extra *testProxyHeader, expectErro return fmt.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/challenge/resolver/solver_manager_test.go b/challenge/resolver/solver_manager_test.go index 59a70378..94085237 100644 --- a/challenge/resolver/solver_manager_test.go +++ b/challenge/resolver/solver_manager_test.go @@ -4,7 +4,7 @@ import ( "crypto/rand" "crypto/rsa" "fmt" - "io/ioutil" + "io" "net/http" "sort" "testing" @@ -14,7 +14,7 @@ import ( "github.com/go-acme/lego/v4/platform/tester" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - jose "gopkg.in/square/go-jose.v2" + "gopkg.in/square/go-jose.v2" ) func TestByType(t *testing.T) { @@ -154,7 +154,7 @@ func TestValidate(t *testing.T) { // or if the JWS body is not the empty JSON payload "{}" or a POST-as-GET payload "" an error is returned. // We use this to verify challenge POSTs to the ts below do not send a JWS body. func validateNoBody(privateKey *rsa.PrivateKey, r *http.Request) error { - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { return err } diff --git a/cmd/accounts_storage.go b/cmd/accounts_storage.go index df398f36..abe08445 100644 --- a/cmd/accounts_storage.go +++ b/cmd/accounts_storage.go @@ -7,7 +7,6 @@ import ( "encoding/pem" "errors" "fmt" - "io/ioutil" "net/url" "os" "path/filepath" @@ -122,11 +121,11 @@ func (s *AccountsStorage) Save(account *Account) error { return err } - return ioutil.WriteFile(s.accountFilePath, jsonBytes, filePerm) + return os.WriteFile(s.accountFilePath, jsonBytes, filePerm) } func (s *AccountsStorage) LoadAccount(privateKey crypto.PrivateKey) *Account { - fileBytes, err := ioutil.ReadFile(s.accountFilePath) + fileBytes, err := os.ReadFile(s.accountFilePath) if err != nil { log.Fatalf("Could not load file for account %s: %v", s.userID, err) } @@ -207,7 +206,7 @@ func generatePrivateKey(file string, keyType certcrypto.KeyType) (crypto.Private } func loadPrivateKey(file string) (crypto.PrivateKey, error) { - keyBytes, err := ioutil.ReadFile(file) + keyBytes, err := os.ReadFile(file) if err != nil { return nil, err } diff --git a/cmd/certs_storage.go b/cmd/certs_storage.go index c3d729d2..d61f265d 100644 --- a/cmd/certs_storage.go +++ b/cmd/certs_storage.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/x509" "encoding/json" - "io/ioutil" "os" "path/filepath" "strconv" @@ -144,7 +143,7 @@ func (s *CertificatesStorage) ExistsFile(domain, extension string) bool { } func (s *CertificatesStorage) ReadFile(domain, extension string) ([]byte, error) { - return ioutil.ReadFile(s.GetFileName(domain, extension)) + return os.ReadFile(s.GetFileName(domain, extension)) } func (s *CertificatesStorage) GetFileName(domain, extension string) string { @@ -172,7 +171,7 @@ func (s *CertificatesStorage) WriteFile(domain, extension string, data []byte) e filePath := filepath.Join(s.rootPath, baseFileName+extension) - return ioutil.WriteFile(filePath, data, filePerm) + return os.WriteFile(filePath, data, filePerm) } func (s *CertificatesStorage) MoveToArchive(domain string) error { diff --git a/cmd/cmd_list.go b/cmd/cmd_list.go index 68fd0c70..100c2a0b 100644 --- a/cmd/cmd_list.go +++ b/cmd/cmd_list.go @@ -3,8 +3,8 @@ package cmd import ( "encoding/json" "fmt" - "io/ioutil" "net/url" + "os" "path/filepath" "strings" @@ -66,7 +66,7 @@ func listCertificates(ctx *cli.Context) error { continue } - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return err } @@ -110,7 +110,7 @@ func listAccount(ctx *cli.Context) error { fmt.Println("Found the following accounts:") for _, filename := range matches { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { return err } diff --git a/cmd/setup.go b/cmd/setup.go index bb70da4a..063c740a 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -4,7 +4,6 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "os" "strings" "time" @@ -98,7 +97,7 @@ func createNonExistingFolder(path string) error { } func readCSRFile(filename string) (*x509.CertificateRequest, error) { - bytes, err := ioutil.ReadFile(filename) + bytes, err := os.ReadFile(filename) if err != nil { return nil, err } diff --git a/e2e/challenges_test.go b/e2e/challenges_test.go index 3d0c9fb6..ea35dc7e 100644 --- a/e2e/challenges_test.go +++ b/e2e/challenges_test.go @@ -6,7 +6,6 @@ import ( "crypto/rsa" "crypto/x509" "fmt" - "io/ioutil" "os" "testing" @@ -333,7 +332,7 @@ func TestChallengeTLS_Client_ObtainForCSR(t *testing.T) { require.NoError(t, err) user.registration = reg - csrRaw, err := ioutil.ReadFile("./fixtures/csr.raw") + csrRaw, err := os.ReadFile("./fixtures/csr.raw") require.NoError(t, err) csr, err := x509.ParseCertificateRequest(csrRaw) diff --git a/go.mod b/go.mod index 5f401205..0eb57e0f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-acme/lego/v4 -go 1.15 +go 1.16 // github.com/exoscale/egoscale v1.19.0 => It is an error, please don't use it. // github.com/linode/linodego v1.0.0 => It is an error, please don't use it. diff --git a/go.sum b/go.sum index c57926ba..cea1fcb2 100644 --- a/go.sum +++ b/go.sum @@ -343,7 +343,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 h1:o6uBwrhM5C8Ll3MAAxrQxRHEu7FkapwTuI2WmL1rw4g= github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY4wsPvgQH/jsuJi4XO2ssZbdsIizr4CVC8= -github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nrdcg/auroradns v1.0.1 h1:m/kBq83Xvy3cU261MOknd8BdnOk12q4lAWM+kOdsC2Y= github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI= @@ -489,7 +488,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277 h1:d9qaMM+ODpCq+9We41//fu/sHsTnXcrqd1en3x+GKy4= diff --git a/internal/dnsdocs/generator.go b/internal/dnsdocs/generator.go index 5f8df98b..a7aa2728 100644 --- a/internal/dnsdocs/generator.go +++ b/internal/dnsdocs/generator.go @@ -9,7 +9,6 @@ import ( "fmt" "go/format" "io" - "io/ioutil" "log" "os" "path/filepath" @@ -201,7 +200,7 @@ func generateReadMe(models *Providers) error { return errors.New("missing end tag") } - return ioutil.WriteFile(readmePath, buffer.Bytes(), 0o666) + return os.WriteFile(readmePath, buffer.Bytes(), 0o666) } func extractTableData(models *Providers) (int, [][]string) { diff --git a/internal/release.go b/internal/release.go index 0b386a33..f3330270 100644 --- a/internal/release.go +++ b/internal/release.go @@ -7,7 +7,6 @@ import ( "go/format" "go/parser" "go/token" - "io/ioutil" "log" "os" "regexp" @@ -186,7 +185,7 @@ func writeUserAgentFile(filename, version, comment string) error { return err } - return ioutil.WriteFile(filename, source, 0o644) + return os.WriteFile(filename, source, 0o644) } func bumpVersion(userAgent, mode string) (string, error) { diff --git a/lego/client_config.go b/lego/client_config.go index 90ad8081..ed8c4a57 100644 --- a/lego/client_config.go +++ b/lego/client_config.go @@ -4,7 +4,6 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" "net" "net/http" "os" @@ -88,7 +87,7 @@ func createDefaultHTTPClient() *http.Client { // caCertificatesEnvVar value then initCertPool will panic. func initCertPool() *x509.CertPool { if customCACertsPath := os.Getenv(caCertificatesEnvVar); customCACertsPath != "" { - customCAs, err := ioutil.ReadFile(customCACertsPath) + customCAs, err := os.ReadFile(customCACertsPath) if err != nil { panic(fmt.Sprintf("error reading %s=%q: %v", caCertificatesEnvVar, customCACertsPath, err)) diff --git a/platform/config/env/env.go b/platform/config/env/env.go index d6428b06..1839529f 100644 --- a/platform/config/env/env.go +++ b/platform/config/env/env.go @@ -3,7 +3,6 @@ package env import ( "errors" "fmt" - "io/ioutil" "os" "strconv" "strings" @@ -155,7 +154,7 @@ func GetOrFile(envVar string) string { return envVarValue } - fileContents, err := ioutil.ReadFile(fileVarValue) + fileContents, err := os.ReadFile(fileVarValue) if err != nil { log.Printf("Failed to read the file %s (defined by env var %s): %s", fileVarValue, fileVar, err) return "" diff --git a/platform/config/env/env_test.go b/platform/config/env/env_test.go index dd938c9c..7b3c52b2 100644 --- a/platform/config/env/env_test.go +++ b/platform/config/env/env_test.go @@ -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"), 0o644) + err = os.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"), 0o644) + err = os.WriteFile(file.Name(), []byte("lego_file"), 0o644) require.NoError(t, err) err = os.Setenv(varEnvFileName, file.Name()) diff --git a/providers/dns/allinkl/internal/client.go b/providers/dns/allinkl/internal/client.go index 37d9eaef..57d560fe 100644 --- a/providers/dns/allinkl/internal/client.go +++ b/providers/dns/allinkl/internal/client.go @@ -6,7 +6,7 @@ import ( "encoding/json" "encoding/xml" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -82,11 +82,11 @@ func (c Client) Authentication(sessionLifetime int, sessionUpdateLifetime bool) defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) return "", fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data)) } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("response read: %w", err) } @@ -206,11 +206,11 @@ func (c Client) do(credentialToken, action string, requestParams interface{}) (* defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data)) } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("response read: %w", err) } diff --git a/providers/dns/arvancloud/internal/client.go b/providers/dns/arvancloud/internal/client.go index b8e44121..abc2f73f 100644 --- a/providers/dns/arvancloud/internal/client.go +++ b/providers/dns/arvancloud/internal/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -70,7 +69,7 @@ func (c *Client) getRecords(domain, search string) ([]DNSRecord, error) { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } @@ -113,7 +112,7 @@ func (c *Client) CreateRecord(domain string, record DNSRecord) (*DNSRecord, erro return nil, err } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } @@ -151,7 +150,7 @@ func (c *Client) DeleteRecord(domain, id string) error { } if resp.StatusCode != http.StatusOK { - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body)) } diff --git a/providers/dns/auroradns/auroradns_test.go b/providers/dns/auroradns/auroradns_test.go index 4a5f669b..9c453e48 100644 --- a/providers/dns/auroradns/auroradns_test.go +++ b/providers/dns/auroradns/auroradns_test.go @@ -2,7 +2,7 @@ package auroradns import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -163,7 +163,7 @@ func TestDNSProvider_Present(t *testing.T) { assert.Equal(t, http.MethodPost, r.Method) assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) require.NoError(t, err) assert.Equal(t, `{"type":"TXT","name":"_acme-challenge","content":"w6uP8Tcg6K2QR905Rms8iXTlksL6OD1KOWBxTK7wxPI","ttl":300}`, string(reqBody)) diff --git a/providers/dns/autodns/client.go b/providers/dns/autodns/client.go index e6fb591e..1c2306c8 100644 --- a/providers/dns/autodns/client.go +++ b/providers/dns/autodns/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "path" "strconv" @@ -132,7 +131,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error { return nil } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -155,7 +154,7 @@ func checkResponse(resp *http.Response) error { defer func() { _ = resp.Body.Close() }() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) } diff --git a/providers/dns/azure/azure.go b/providers/dns/azure/azure.go index 7289592f..cf47a518 100644 --- a/providers/dns/azure/azure.go +++ b/providers/dns/azure/azure.go @@ -6,7 +6,7 @@ import ( "context" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strings" "time" @@ -319,7 +319,7 @@ func getMetadata(config *Config, field string) (string, error) { } defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return "", err } diff --git a/providers/dns/bluecat/bluecat.go b/providers/dns/bluecat/bluecat.go index 4d197dfc..afc864dd 100644 --- a/providers/dns/bluecat/bluecat.go +++ b/providers/dns/bluecat/bluecat.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -139,7 +139,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } defer resp.Body.Close() - addTxtBytes, _ := ioutil.ReadAll(resp.Body) + addTxtBytes, _ := io.ReadAll(resp.Body) addTxtResp := string(addTxtBytes) // addEntity responds only with body text containing the ID of the created record _, err = strconv.ParseUint(addTxtResp, 10, 64) diff --git a/providers/dns/bluecat/client.go b/providers/dns/bluecat/client.go index 9ee0fd2f..5f6aff3f 100644 --- a/providers/dns/bluecat/client.go +++ b/providers/dns/bluecat/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strconv" @@ -41,7 +41,7 @@ func (d *DNSProvider) login() error { } defer resp.Body.Close() - authBytes, err := ioutil.ReadAll(resp.Body) + authBytes, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("bluecat: %w", err) } @@ -74,7 +74,7 @@ func (d *DNSProvider) logout() error { return fmt.Errorf("bluecat: request failed to delete session with HTTP status code %d", resp.StatusCode) } - authBytes, err := ioutil.ReadAll(resp.Body) + authBytes, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -240,7 +240,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, } if resp.StatusCode >= 400 { - errBytes, _ := ioutil.ReadAll(resp.Body) + errBytes, _ := io.ReadAll(resp.Body) errResp := string(errBytes) return nil, fmt.Errorf("bluecat: request failed with HTTP status code %d\n Full message: %s", resp.StatusCode, errResp) diff --git a/providers/dns/checkdomain/client.go b/providers/dns/checkdomain/client.go index eb627807..8b401a7e 100644 --- a/providers/dns/checkdomain/client.go +++ b/providers/dns/checkdomain/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strconv" "strings" @@ -385,7 +384,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error { return nil } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -408,7 +407,7 @@ func checkResponse(resp *http.Response) error { defer func() { _ = resp.Body.Close() }() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) } diff --git a/providers/dns/checkdomain/client_test.go b/providers/dns/checkdomain/client_test.go index efc75101..959c3e08 100644 --- a/providers/dns/checkdomain/client_test.go +++ b/providers/dns/checkdomain/client_test.go @@ -3,7 +3,7 @@ package checkdomain import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -99,7 +99,7 @@ func Test_createRecord(t *testing.T) { return } - content, err := ioutil.ReadAll(req.Body) + content, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusBadRequest) return diff --git a/providers/dns/clouddns/internal/client.go b/providers/dns/clouddns/internal/client.go index 43958080..b4d1154f 100644 --- a/providers/dns/clouddns/internal/client.go +++ b/providers/dns/clouddns/internal/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" ) @@ -235,7 +234,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) { return nil, readError(req, resp) } - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return nil, err } @@ -243,7 +242,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) { } func readError(req *http.Request, resp *http.Response) error { - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return errors.New(toUnreadableBodyMessage(req, content)) } diff --git a/providers/dns/cloudns/internal/client.go b/providers/dns/cloudns/internal/client.go index 4a994244..8208133e 100644 --- a/providers/dns/cloudns/internal/client.go +++ b/providers/dns/cloudns/internal/client.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -278,7 +278,7 @@ func (c *Client) doRequest(method string, uri *url.URL) (json.RawMessage, error) defer resp.Body.Close() - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.New(toUnreadableBodyMessage(req, content)) } diff --git a/providers/dns/cloudxns/internal/client.go b/providers/dns/cloudxns/internal/client.go index 6f4e211e..8a1c100c 100644 --- a/providers/dns/cloudxns/internal/client.go +++ b/providers/dns/cloudxns/internal/client.go @@ -7,7 +7,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -164,7 +164,7 @@ func (c *Client) doRequest(method, uri string, body []byte) (json.RawMessage, er defer resp.Body.Close() - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("CloudXNS: %s", toUnreadableBodyMessage(req, content)) } diff --git a/providers/dns/cloudxns/internal/client_test.go b/providers/dns/cloudxns/internal/client_test.go index 2036e7b8..dbf5de49 100644 --- a/providers/dns/cloudxns/internal/client_test.go +++ b/providers/dns/cloudxns/internal/client_test.go @@ -3,7 +3,7 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -267,7 +267,7 @@ func TestClientAddTxtRecord(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { assert.NotNil(t, req.Body) - content, err := ioutil.ReadAll(req.Body) + content, err := io.ReadAll(req.Body) require.NoError(t, err) assert.Equal(t, test.expected, string(content)) diff --git a/providers/dns/conoha/internal/client.go b/providers/dns/conoha/internal/client.go index e9fd004b..f8a5e192 100644 --- a/providers/dns/conoha/internal/client.go +++ b/providers/dns/conoha/internal/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -182,7 +182,7 @@ func (c *Client) do(method, path string, payload, result interface{}) error { } if resp.StatusCode != http.StatusOK { - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -192,7 +192,7 @@ func (c *Client) do(method, path string, payload, result interface{}) error { } if result != nil { - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/conoha/internal/client_test.go b/providers/dns/conoha/internal/client_test.go index cee3580f..46c98005 100644 --- a/providers/dns/conoha/internal/client_test.go +++ b/providers/dns/conoha/internal/client_test.go @@ -2,7 +2,7 @@ package internal import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -151,7 +151,7 @@ func TestClient_CreateRecord(t *testing.T) { return } - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusBadRequest) return diff --git a/providers/dns/constellix/internal/client.go b/providers/dns/constellix/internal/client.go index 5f4db2df..4d4951ac 100644 --- a/providers/dns/constellix/internal/client.go +++ b/providers/dns/constellix/internal/client.go @@ -3,7 +3,7 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -63,7 +63,7 @@ func (c *Client) do(req *http.Request, v interface{}) error { return err } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read body: %w", err) } @@ -94,7 +94,7 @@ func checkResponse(resp *http.Response) error { return nil } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err == nil && data != nil { msg := &APIError{StatusCode: resp.StatusCode} diff --git a/providers/dns/constellix/internal/txtrecords_test.go b/providers/dns/constellix/internal/txtrecords_test.go index 9d0397c9..b14980de 100644 --- a/providers/dns/constellix/internal/txtrecords_test.go +++ b/providers/dns/constellix/internal/txtrecords_test.go @@ -3,7 +3,6 @@ package internal import ( "encoding/json" "io" - "io/ioutil" "net/http" "os" "testing" @@ -42,7 +41,7 @@ func TestTxtRecordService_Create(t *testing.T) { recordsJSON, err := json.Marshal(records) require.NoError(t, err) - expectedContent, err := ioutil.ReadFile("./fixtures/records-Create.json") + expectedContent, err := os.ReadFile("./fixtures/records-Create.json") require.NoError(t, err) assert.JSONEq(t, string(expectedContent), string(recordsJSON)) @@ -78,7 +77,7 @@ func TestTxtRecordService_GetAll(t *testing.T) { recordsJSON, err := json.Marshal(records) require.NoError(t, err) - expectedContent, err := ioutil.ReadFile("./fixtures/records-GetAll.json") + expectedContent, err := os.ReadFile("./fixtures/records-GetAll.json") require.NoError(t, err) assert.JSONEq(t, string(expectedContent), string(recordsJSON)) @@ -211,7 +210,7 @@ func TestTxtRecordService_Search(t *testing.T) { recordsJSON, err := json.Marshal(records) require.NoError(t, err) - expectedContent, err := ioutil.ReadFile("./fixtures/records-Search.json") + expectedContent, err := os.ReadFile("./fixtures/records-Search.json") require.NoError(t, err) assert.JSONEq(t, string(expectedContent), string(recordsJSON)) diff --git a/providers/dns/digitalocean/client.go b/providers/dns/digitalocean/client.go index 4223307e..d89eb598 100644 --- a/providers/dns/digitalocean/client.go +++ b/providers/dns/digitalocean/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "github.com/go-acme/lego/v4/challenge/dns01" @@ -85,7 +84,7 @@ func (d *DNSProvider) addTxtRecord(fqdn, value string) (*txtRecordResponse, erro return nil, readError(req, resp) } - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.New(toUnreadableBodyMessage(req, content)) } @@ -113,7 +112,7 @@ func (d *DNSProvider) newRequest(method, reqURL string, body io.Reader) (*http.R } func readError(req *http.Request, resp *http.Response) error { - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return errors.New(toUnreadableBodyMessage(req, content)) } diff --git a/providers/dns/digitalocean/digitalocean_test.go b/providers/dns/digitalocean/digitalocean_test.go index 2d631860..9dd608d7 100644 --- a/providers/dns/digitalocean/digitalocean_test.go +++ b/providers/dns/digitalocean/digitalocean_test.go @@ -2,7 +2,7 @@ package digitalocean import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -117,7 +117,7 @@ func TestDNSProvider_Present(t *testing.T) { assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") assert.Equal(t, "Bearer asdf1234", r.Header.Get("Authorization"), "Authorization") - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/providers/dns/dnsmadeeasy/internal/client.go b/providers/dns/dnsmadeeasy/internal/client.go index c0960acd..85d18a0f 100644 --- a/providers/dns/dnsmadeeasy/internal/client.go +++ b/providers/dns/dnsmadeeasy/internal/client.go @@ -8,7 +8,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -153,7 +153,7 @@ func (c *Client) sendRequest(method, resource string, payload interface{}) (*htt } if resp.StatusCode > 299 { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode) } diff --git a/providers/dns/dode/client.go b/providers/dns/dode/client.go index 357dc0d1..d788c1a7 100644 --- a/providers/dns/dode/client.go +++ b/providers/dns/dode/client.go @@ -3,7 +3,7 @@ package dode import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/url" "github.com/go-acme/lego/v4/challenge/dns01" @@ -38,7 +38,7 @@ func (d *DNSProvider) updateTxtRecord(fqdn, token, txt string, clear bool) error } defer response.Body.Close() - bodyBytes, err := ioutil.ReadAll(response.Body) + bodyBytes, err := io.ReadAll(response.Body) if err != nil { return err } diff --git a/providers/dns/domeneshop/internal/client.go b/providers/dns/domeneshop/internal/client.go index 0aca84c3..f578fb42 100644 --- a/providers/dns/domeneshop/internal/client.go +++ b/providers/dns/domeneshop/internal/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -119,7 +119,7 @@ func (c *Client) doRequest(method string, endpoint string, reqBody []byte, v int defer func() { _ = resp.Body.Close() }() if resp.StatusCode >= http.StatusBadRequest { - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/dreamhost/client.go b/providers/dns/dreamhost/client.go index 6ea23664..801751c8 100644 --- a/providers/dns/dreamhost/client.go +++ b/providers/dns/dreamhost/client.go @@ -3,7 +3,7 @@ package dreamhost import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/url" "github.com/go-acme/lego/v4/log" @@ -53,7 +53,7 @@ func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error { return fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode) } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read body: %w", err) } diff --git a/providers/dns/duckdns/client.go b/providers/dns/duckdns/client.go index 37593376..5eb9cb44 100644 --- a/providers/dns/duckdns/client.go +++ b/providers/dns/duckdns/client.go @@ -2,7 +2,7 @@ package duckdns import ( "fmt" - "io/ioutil" + "io" "net/url" "strconv" "strings" @@ -35,7 +35,7 @@ func (d *DNSProvider) updateTxtRecord(domain, token, txt string, clear bool) err } defer response.Body.Close() - bodyBytes, err := ioutil.ReadAll(response.Body) + bodyBytes, err := io.ReadAll(response.Body) if err != nil { return err } diff --git a/providers/dns/dynu/internal/client.go b/providers/dns/dynu/internal/client.go index c6e22cf4..93ee9f15 100644 --- a/providers/dns/dynu/internal/client.go +++ b/providers/dns/dynu/internal/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -164,7 +163,7 @@ func (c Client) doRetry(method, uri string, body []byte, data interface{}) error defer func() { _ = resp.Body.Close() }() - all, err := ioutil.ReadAll(resp.Body) + all, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read response body: %w", err) } diff --git a/providers/dns/easydns/client.go b/providers/dns/easydns/client.go index 36465389..49922e33 100644 --- a/providers/dns/easydns/client.go +++ b/providers/dns/easydns/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "path" ) @@ -81,7 +81,7 @@ func (d *DNSProvider) doRequest(method, resource string, requestMsg, responseMsg defer response.Body.Close() if response.StatusCode >= http.StatusBadRequest { - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) if err != nil { return fmt.Errorf("%d: failed to read response body: %w", response.StatusCode, err) } diff --git a/providers/dns/easydns/easydns_test.go b/providers/dns/easydns/easydns_test.go index 47fe5ac1..984d8051 100644 --- a/providers/dns/easydns/easydns_test.go +++ b/providers/dns/easydns/easydns_test.go @@ -2,7 +2,7 @@ package easydns import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -152,7 +152,7 @@ func TestDNSProvider_Present(t *testing.T) { assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") assert.Equal(t, "Basic VE9LRU46U0VDUkVU", r.Header.Get("Authorization"), "Authorization") - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/providers/dns/gandi/client.go b/providers/dns/gandi/client.go index f9f30f67..acdc8a4c 100644 --- a/providers/dns/gandi/client.go +++ b/providers/dns/gandi/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" ) // types for XML-RPC method calls and parameters @@ -314,7 +313,7 @@ func (d *DNSProvider) httpPost(url, bodyType string, body io.Reader) ([]byte, er } defer resp.Body.Close() - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.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 1a72a714..4ee919e3 100644 --- a/providers/dns/gandi/gandi_test.go +++ b/providers/dns/gandi/gandi_test.go @@ -2,7 +2,6 @@ package gandi import ( "io" - "io/ioutil" "net/http" "net/http/httptest" "regexp" @@ -128,7 +127,7 @@ func TestDNSProvider(t *testing.T) { fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { require.Equal(t, "text/xml", r.Header.Get("Content-Type"), "invalid content type") - req, errS := ioutil.ReadAll(r.Body) + req, errS := io.ReadAll(r.Body) require.NoError(t, errS) req = regexpDate.ReplaceAllLiteral(req, []byte(`[ACME Challenge 01 Jan 16 00:00 +0000]`)) diff --git a/providers/dns/gandiv5/client.go b/providers/dns/gandiv5/client.go index 0ddbfe2a..106fa08c 100644 --- a/providers/dns/gandiv5/client.go +++ b/providers/dns/gandiv5/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "github.com/go-acme/lego/v4/log" @@ -191,7 +191,7 @@ func readBody(resp *http.Response) ([]byte, error) { defer resp.Body.Close() - rawBody, err := ioutil.ReadAll(resp.Body) + rawBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/gandiv5/gandiv5_test.go b/providers/dns/gandiv5/gandiv5_test.go index 8b3a9e96..d56733ff 100644 --- a/providers/dns/gandiv5/gandiv5_test.go +++ b/providers/dns/gandiv5/gandiv5_test.go @@ -2,7 +2,7 @@ package gandiv5 import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "regexp" @@ -128,7 +128,7 @@ func TestDNSProvider(t *testing.T) { return } - body, errS := ioutil.ReadAll(req.Body) + body, errS := io.ReadAll(req.Body) if errS != nil { http.Error(rw, fmt.Sprintf(`{"message": "read body error: %v"}`, errS), http.StatusInternalServerError) return diff --git a/providers/dns/gcloud/googlecloud.go b/providers/dns/gcloud/googlecloud.go index 271675eb..db1c19ac 100644 --- a/providers/dns/gcloud/googlecloud.go +++ b/providers/dns/gcloud/googlecloud.go @@ -5,8 +5,8 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "net/http" + "os" "strconv" "time" @@ -145,7 +145,7 @@ func NewDNSProviderServiceAccount(saFile string) (*DNSProvider, error) { return nil, errors.New("googlecloud: Service Account file missing") } - saKey, err := ioutil.ReadFile(saFile) + saKey, err := os.ReadFile(saFile) if err != nil { return nil, fmt.Errorf("googlecloud: unable to read Service Account file: %w", err) } diff --git a/providers/dns/gcore/internal/client.go b/providers/dns/gcore/internal/client.go index 99f25ac9..25c30feb 100644 --- a/providers/dns/gcore/internal/client.go +++ b/providers/dns/gcore/internal/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -142,7 +142,7 @@ func (c *Client) do(ctx context.Context, method, uri string, bodyParams interfac defer func() { _ = resp.Body.Close() }() if resp.StatusCode/100 != 2 { - all, _ := ioutil.ReadAll(resp.Body) + all, _ := io.ReadAll(resp.Body) e := APIError{ StatusCode: resp.StatusCode, diff --git a/providers/dns/godaddy/client.go b/providers/dns/godaddy/client.go index d30001e8..d78d7890 100644 --- a/providers/dns/godaddy/client.go +++ b/providers/dns/godaddy/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "path" ) @@ -30,7 +29,7 @@ func (d *DNSProvider) getRecords(domainZone, rType, recordName string) ([]DNSRec defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("could not get records: Domain: %s; Record: %s, Status: %v; Body: %s", domainZone, recordName, resp.StatusCode, string(bodyBytes)) } @@ -61,7 +60,7 @@ func (d *DNSProvider) updateTxtRecords(records []DNSRecord, domainZone, recordNa defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) return fmt.Errorf("could not create record %v; Status: %v; Body: %s", string(body), resp.StatusCode, string(bodyBytes)) } diff --git a/providers/dns/hetzner/internal/client.go b/providers/dns/hetzner/internal/client.go index c1ab8114..f90439b2 100644 --- a/providers/dns/hetzner/internal/client.go +++ b/providers/dns/hetzner/internal/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -68,7 +67,7 @@ func (c *Client) getRecords(zoneID string) (*DNSRecords, error) { defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("could not get records: zone ID: %s; Status: %s; Body: %s", zoneID, resp.Status, string(bodyBytes)) } @@ -101,7 +100,7 @@ func (c *Client) CreateRecord(record DNSRecord) error { } if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) return fmt.Errorf("could not create record %s; Status: %s; Body: %s", string(body), resp.Status, string(bodyBytes)) } diff --git a/providers/dns/hostingde/client.go b/providers/dns/hostingde/client.go index 9af1b0ac..047bb740 100644 --- a/providers/dns/hostingde/client.go +++ b/providers/dns/hostingde/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -105,7 +105,7 @@ func (d *DNSProvider) post(uri string, request, response interface{}) ([]byte, e defer resp.Body.Close() - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.New(toUnreadableBodyMessage(uri, content)) } diff --git a/providers/dns/hosttech/internal/client.go b/providers/dns/hosttech/internal/client.go index 4af0f42c..8108438a 100644 --- a/providers/dns/hosttech/internal/client.go +++ b/providers/dns/hosttech/internal/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -198,7 +198,7 @@ func (c Client) do(req *http.Request) (json.RawMessage, error) { switch resp.StatusCode { case http.StatusOK, http.StatusCreated: - all, err := ioutil.ReadAll(resp.Body) + all, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("read response: %w", err) } @@ -215,7 +215,7 @@ func (c Client) do(req *http.Request) (json.RawMessage, error) { return nil, nil default: - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) e := APIError{StatusCode: resp.StatusCode} err := json.Unmarshal(data, &e) diff --git a/providers/dns/httpreq/httpreq.go b/providers/dns/httpreq/httpreq.go index 887f2b84..55f2725d 100644 --- a/providers/dns/httpreq/httpreq.go +++ b/providers/dns/httpreq/httpreq.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -196,7 +196,7 @@ func (d *DNSProvider) doPost(uri string, msg interface{}) error { defer resp.Body.Close() if resp.StatusCode >= http.StatusBadRequest { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err) } diff --git a/providers/dns/hurricane/internal/client.go b/providers/dns/hurricane/internal/client.go index 38696f40..5acdb4bf 100644 --- a/providers/dns/hurricane/internal/client.go +++ b/providers/dns/hurricane/internal/client.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/url" @@ -81,7 +81,7 @@ func (c *Client) UpdateTxtRecord(ctx context.Context, domain string, txt string) defer func() { _ = resp.Body.Close() }() - bodyBytes, err := ioutil.ReadAll(resp.Body) + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/hyperone/internal/client.go b/providers/dns/hyperone/internal/client.go index c21b7f66..125315c4 100644 --- a/providers/dns/hyperone/internal/client.go +++ b/providers/dns/hyperone/internal/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -291,7 +290,7 @@ func (c *Client) do(req *http.Request, v interface{}) error { return nil } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read body: %w", err) } @@ -316,7 +315,7 @@ func checkResponse(resp *http.Response) error { } // add response body to error message if not empty - responseBody, _ := ioutil.ReadAll(resp.Body) + responseBody, _ := io.ReadAll(resp.Body) if len(responseBody) > 0 { msg = fmt.Sprintf("%s: %s", msg, string(responseBody)) } diff --git a/providers/dns/hyperone/internal/client_test.go b/providers/dns/hyperone/internal/client_test.go index e1844eba..84c6afb6 100644 --- a/providers/dns/hyperone/internal/client_test.go +++ b/providers/dns/hyperone/internal/client_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -186,7 +185,7 @@ type assertHandler func(http.ResponseWriter, *http.Request) (int, error) func hasReqBody(v interface{}) assertHandler { return func(rw http.ResponseWriter, req *http.Request) (int, error) { - reqBody, err := ioutil.ReadAll(req.Body) + reqBody, err := io.ReadAll(req.Body) if err != nil { return http.StatusBadRequest, err } diff --git a/providers/dns/infomaniak/internal/client.go b/providers/dns/infomaniak/internal/client.go index 4234a041..bd55f9b9 100644 --- a/providers/dns/infomaniak/internal/client.go +++ b/providers/dns/infomaniak/internal/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -143,7 +142,7 @@ func (c *Client) do(req *http.Request) (*APIResponse, error) { defer func() { _ = rawResp.Body.Close() }() - content, err := ioutil.ReadAll(rawResp.Body) + content, err := io.ReadAll(rawResp.Body) if err != nil { return nil, fmt.Errorf("failed to read the response body, status code: %d", rawResp.StatusCode) } diff --git a/providers/dns/infomaniak/internal/client_test.go b/providers/dns/infomaniak/internal/client_test.go index 21c1c97a..87ae3858 100644 --- a/providers/dns/infomaniak/internal/client_test.go +++ b/providers/dns/infomaniak/internal/client_test.go @@ -2,7 +2,7 @@ package internal import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -35,7 +35,7 @@ func TestClient_CreateDNSRecord(t *testing.T) { return } - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusBadRequest) return diff --git a/providers/dns/internal/rimuhosting/client.go b/providers/dns/internal/rimuhosting/client.go index e71d2e26..9b563140 100644 --- a/providers/dns/internal/rimuhosting/client.go +++ b/providers/dns/internal/rimuhosting/client.go @@ -3,7 +3,7 @@ package rimuhosting import ( "encoding/xml" "errors" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -132,7 +132,7 @@ func (c Client) do(params, data interface{}) error { defer func() { _ = resp.Body.Close() }() - all, err := ioutil.ReadAll(resp.Body) + all, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/internal/selectel/client.go b/providers/dns/internal/selectel/client.go index da3fd3ae..92e4746f 100644 --- a/providers/dns/internal/selectel/client.go +++ b/providers/dns/internal/selectel/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" ) @@ -149,7 +149,7 @@ func checkResponse(resp *http.Response) error { return fmt.Errorf("request failed with status code %d and empty body", resp.StatusCode) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -168,7 +168,7 @@ func checkResponse(resp *http.Response) error { } func unmarshalBody(resp *http.Response, to interface{}) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/internetbs/internal/client.go b/providers/dns/internetbs/internal/client.go index 767de2ad..b5eebf73 100644 --- a/providers/dns/internetbs/internal/client.go +++ b/providers/dns/internetbs/internal/client.go @@ -3,9 +3,10 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" + "os" "path" "path/filepath" "strings" @@ -110,7 +111,7 @@ func (c Client) do(action string, params interface{}, response interface{}) erro defer func() { _ = resp.Body.Close() }() if resp.StatusCode/100 != 2 { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) return fmt.Errorf("status code: %d, %s", resp.StatusCode, string(data)) } @@ -122,7 +123,7 @@ func (c Client) do(action string, params interface{}, response interface{}) erro } func dump(endpoint *url.URL, resp *http.Response, response interface{}) error { - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -131,7 +132,7 @@ func dump(endpoint *url.URL, resp *http.Response, response interface{}) error { return !unicode.IsLetter(r) && !unicode.IsNumber(r) }) - err = ioutil.WriteFile(filepath.Join("fixtures", strings.Join(fields, "_")+".json"), data, 0o666) + err = os.WriteFile(filepath.Join("fixtures", strings.Join(fields, "_")+".json"), data, 0o666) if err != nil { return err } diff --git a/providers/dns/ionos/internal/client.go b/providers/dns/ionos/internal/client.go index d1ab0d9f..6bee19f7 100644 --- a/providers/dns/ionos/internal/client.go +++ b/providers/dns/ionos/internal/client.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -168,7 +167,7 @@ func (c *Client) makeRequest(ctx context.Context, method, uri string, body io.Re } func readError(body io.Reader, statusCode int) error { - bodyBytes, _ := ioutil.ReadAll(body) + bodyBytes, _ := io.ReadAll(body) cErr := &ClientError{StatusCode: statusCode} diff --git a/providers/dns/joker/internal/dmapi/client.go b/providers/dns/joker/internal/dmapi/client.go index c02cf197..e8e97c3a 100644 --- a/providers/dns/joker/internal/dmapi/client.go +++ b/providers/dns/joker/internal/dmapi/client.go @@ -5,7 +5,7 @@ package dmapi import ( "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -149,7 +149,7 @@ func (c *Client) postRequest(cmd string, data url.Values) (*Response, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/joker/internal/svc/client.go b/providers/dns/joker/internal/svc/client.go index 2790377f..28b98432 100644 --- a/providers/dns/joker/internal/svc/client.go +++ b/providers/dns/joker/internal/svc/client.go @@ -4,7 +4,7 @@ package svc import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" @@ -59,7 +59,7 @@ func (c *Client) Send(zone, label, value string) error { return err } - all, err := ioutil.ReadAll(resp.Body) + all, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/joker/internal/svc/client_test.go b/providers/dns/joker/internal/svc/client_test.go index 542d3b5c..422352e6 100644 --- a/providers/dns/joker/internal/svc/client_test.go +++ b/providers/dns/joker/internal/svc/client_test.go @@ -2,7 +2,7 @@ package svc import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -20,7 +20,7 @@ func TestClient_Send(t *testing.T) { return } - all, _ := ioutil.ReadAll(req.Body) + all, _ := io.ReadAll(req.Body) if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=123&zone=example.com" { http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest) @@ -54,7 +54,7 @@ func TestClient_Send_empty(t *testing.T) { return } - all, _ := ioutil.ReadAll(req.Body) + all, _ := io.ReadAll(req.Body) if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=&zone=example.com" { http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest) diff --git a/providers/dns/liquidweb/liquidweb_test.go b/providers/dns/liquidweb/liquidweb_test.go index 91221cb0..b0034aed 100644 --- a/providers/dns/liquidweb/liquidweb_test.go +++ b/providers/dns/liquidweb/liquidweb_test.go @@ -2,7 +2,7 @@ package liquidweb import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -184,7 +184,7 @@ func TestDNSProvider_Present(t *testing.T) { assert.Equal(t, "tacoman", password) assert.True(t, ok) - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/providers/dns/loopia/internal/client.go b/providers/dns/loopia/internal/client.go index 3c9a92c0..013e5a99 100644 --- a/providers/dns/loopia/internal/client.go +++ b/providers/dns/loopia/internal/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strings" "time" @@ -167,7 +166,7 @@ func (c *Client) httpPost(url string, bodyType string, body io.Reader) ([]byte, return nil, fmt.Errorf("HTTP Post Error: %d", resp.StatusCode) } - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("HTTP Post Error: %w", err) } diff --git a/providers/dns/loopia/internal/client_test.go b/providers/dns/loopia/internal/client_test.go index a3c55120..1f75be98 100644 --- a/providers/dns/loopia/internal/client_test.go +++ b/providers/dns/loopia/internal/client_test.go @@ -3,7 +3,7 @@ package internal import ( "encoding/xml" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -210,7 +210,7 @@ func TestClient_GetZoneRecord(t *testing.T) { func TestClient_rpcCall_404(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, err := ioutil.ReadAll(r.Body) + _, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -243,7 +243,7 @@ func TestClient_rpcCall_404(t *testing.T) { func TestClient_rpcCall_RPCError(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, err := ioutil.ReadAll(r.Body) + _, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -310,7 +310,7 @@ func createFakeServer(t *testing.T, serverResponses map[string]string) string { return } - req, err := ioutil.ReadAll(r.Body) + req, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/providers/dns/luadns/internal/client.go b/providers/dns/luadns/internal/client.go index 565405f4..6f853cc2 100644 --- a/providers/dns/luadns/internal/client.go +++ b/providers/dns/luadns/internal/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" ) @@ -42,7 +41,7 @@ func (d *Client) ListZones() ([]DNSZone, error) { defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) var errResp errorResponse err = json.Unmarshal(bodyBytes, &errResp) @@ -80,7 +79,7 @@ func (d *Client) CreateRecord(zone DNSZone, newRecord DNSRecord) (*DNSRecord, er defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) var errResp errorResponse err = json.Unmarshal(bodyBytes, &errResp) @@ -120,7 +119,7 @@ func (d *Client) DeleteRecord(record *DNSRecord) error { defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) var errResp errorResponse err = json.Unmarshal(bodyBytes, &errResp) diff --git a/providers/dns/mydnsjp/client.go b/providers/dns/mydnsjp/client.go index 3bb72fae..394ab818 100644 --- a/providers/dns/mydnsjp/client.go +++ b/providers/dns/mydnsjp/client.go @@ -2,7 +2,7 @@ package mydnsjp import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -23,7 +23,7 @@ func (d *DNSProvider) doRequest(domain, value, cmd string) error { if resp.StatusCode >= 400 { var content []byte - content, err = ioutil.ReadAll(resp.Body) + content, err = io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/dns/mythicbeasts/client.go b/providers/dns/mythicbeasts/client.go index b4b29dc1..c7940637 100644 --- a/providers/dns/mythicbeasts/client.go +++ b/providers/dns/mythicbeasts/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "path" "strings" @@ -83,7 +83,7 @@ func (d *DNSProvider) login() error { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("login: %w", err) } @@ -159,7 +159,7 @@ func (d *DNSProvider) createTXTRecord(zone, leaf, value string) error { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("createTXTRecord: %w", err) } @@ -211,7 +211,7 @@ func (d *DNSProvider) removeTXTRecord(zone, leaf, value string) error { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("removeTXTRecord: %w", err) } diff --git a/providers/dns/namecheap/client.go b/providers/dns/namecheap/client.go index 9fd6eefb..f81f8c13 100644 --- a/providers/dns/namecheap/client.go +++ b/providers/dns/namecheap/client.go @@ -4,7 +4,7 @@ import ( "encoding/xml" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -180,7 +180,7 @@ func readBody(resp *http.Response) ([]byte, error) { defer resp.Body.Close() - rawBody, err := ioutil.ReadAll(resp.Body) + rawBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/namecheap/namecheap.go b/providers/dns/namecheap/namecheap.go index ed1f8dd2..4f185ec7 100644 --- a/providers/dns/namecheap/namecheap.go +++ b/providers/dns/namecheap/namecheap.go @@ -4,7 +4,7 @@ package namecheap import ( "errors" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -220,7 +220,7 @@ func getClientIP(client *http.Client, debug bool) (addr string, err error) { } defer resp.Body.Close() - clientIP, err := ioutil.ReadAll(resp.Body) + clientIP, err := io.ReadAll(resp.Body) if err != nil { return "", err } diff --git a/providers/dns/netcup/internal/client.go b/providers/dns/netcup/internal/client.go index a7e9d2e3..58b58445 100644 --- a/providers/dns/netcup/internal/client.go +++ b/providers/dns/netcup/internal/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -282,7 +282,7 @@ func checkResponse(resp *http.Response) error { defer resp.Body.Close() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) } @@ -300,7 +300,7 @@ func decodeResponseMsg(resp *http.Response) (*ResponseMsg, error) { defer resp.Body.Close() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) } diff --git a/providers/dns/netcup/internal/client_test.go b/providers/dns/netcup/internal/client_test.go index 490cb0e3..fd28dca2 100644 --- a/providers/dns/netcup/internal/client_test.go +++ b/providers/dns/netcup/internal/client_test.go @@ -2,7 +2,7 @@ package internal import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strconv" @@ -141,7 +141,7 @@ func TestClient_Login(t *testing.T) { defer tearDown() mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) } @@ -251,7 +251,7 @@ func TestClient_Logout(t *testing.T) { defer tearDown() mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) } @@ -335,7 +335,7 @@ func TestClient_GetDNSRecords(t *testing.T) { defer tearDown() mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) } @@ -443,7 +443,7 @@ func TestClient_GetDNSRecords_errors(t *testing.T) { { desc: "responsedata marshaling error", handler: func(rw http.ResponseWriter, req *http.Request) { - raw, err := ioutil.ReadAll(req.Body) + raw, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) } diff --git a/providers/dns/netlify/internal/client.go b/providers/dns/netlify/internal/client.go index 4d409e28..1f521ca3 100644 --- a/providers/dns/netlify/internal/client.go +++ b/providers/dns/netlify/internal/client.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -51,7 +51,7 @@ func (c *Client) GetRecords(zoneID string) ([]DNSRecord, error) { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } @@ -97,7 +97,7 @@ func (c *Client) CreateRecord(zoneID string, record DNSRecord) (*DNSRecord, erro defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } @@ -137,7 +137,7 @@ func (c *Client) RemoveRecord(zoneID, recordID string) error { defer func() { _ = resp.Body.Close() }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read response body: %w", err) } diff --git a/providers/dns/oraclecloud/configprovider.go b/providers/dns/oraclecloud/configprovider.go index fa78705e..e5fa66da 100644 --- a/providers/dns/oraclecloud/configprovider.go +++ b/providers/dns/oraclecloud/configprovider.go @@ -4,7 +4,6 @@ import ( "crypto/rsa" "encoding/base64" "fmt" - "io/ioutil" "os" "github.com/go-acme/lego/v4/platform/config/env" @@ -83,7 +82,7 @@ func getPrivateKey(envVar string) ([]byte, error) { return nil, fmt.Errorf("no value provided for: %s or %s", envVar, fileVar) } - fileContents, err := ioutil.ReadFile(fileVarValue) + fileContents, err := os.ReadFile(fileVarValue) if err != nil { return nil, fmt.Errorf("failed to read the file %s (defined by env var %s): %w", fileVarValue, fileVar, err) } diff --git a/providers/dns/otc/client.go b/providers/dns/otc/client.go index ce8a3a9f..21b5d1c5 100644 --- a/providers/dns/otc/client.go +++ b/providers/dns/otc/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" ) @@ -258,7 +257,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode) } - body1, err := ioutil.ReadAll(resp.Body) + body1, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/otc/mock_test.go b/providers/dns/otc/mock_test.go index b52f0404..706d94f9 100644 --- a/providers/dns/otc/mock_test.go +++ b/providers/dns/otc/mock_test.go @@ -2,7 +2,7 @@ package otc import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -147,7 +147,7 @@ func (m *DNSServerMock) HandleListRecordsetsSuccessfully() { if r.Method == http.MethodPost { assert.Equal(m.t, r.Header.Get("Content-Type"), "application/json") - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) assert.Nil(m.t, err) exceptedString := `{ "name": "_acme-challenge.example.com.", diff --git a/providers/dns/rackspace/rackspace_test.go b/providers/dns/rackspace/rackspace_test.go index 27ff0a59..0ad4940f 100644 --- a/providers/dns/rackspace/rackspace_test.go +++ b/providers/dns/rackspace/rackspace_test.go @@ -2,7 +2,7 @@ package rackspace import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -124,7 +124,7 @@ func startTestServers() (string, func()) { func identityHandler(dnsEndpoint string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { w.WriteHeader(http.StatusInternalServerError) return @@ -158,7 +158,7 @@ func dnsHandler() *http.ServeMux { switch r.Method { // Used by `Present()` creating the TXT record case http.MethodPost: - reqBody, err := ioutil.ReadAll(r.Body) + reqBody, err := io.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/providers/dns/regru/internal/client.go b/providers/dns/regru/internal/client.go index b6691cd7..34ca07e3 100644 --- a/providers/dns/regru/internal/client.go +++ b/providers/dns/regru/internal/client.go @@ -3,7 +3,7 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -102,7 +102,7 @@ func (c Client) do(request interface{}, fragments ...string) (*APIResponse, erro return nil, fmt.Errorf("API error, status code: %d", resp.StatusCode) } - all, err := ioutil.ReadAll(resp.Body) + all, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/servercow/internal/client.go b/providers/dns/servercow/internal/client.go index 963d9d99..556a18dc 100644 --- a/providers/dns/servercow/internal/client.go +++ b/providers/dns/servercow/internal/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -48,7 +48,7 @@ func (c *Client) GetRecords(domain string) ([]Record, error) { return nil, fmt.Errorf("error: status code %d", resp.StatusCode) } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read body: %w", err) } @@ -80,7 +80,7 @@ func (c *Client) CreateUpdateRecord(domain string, data Record) (*Message, error return nil, fmt.Errorf("error: status code %d", resp.StatusCode) } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read body: %w", err) } @@ -116,7 +116,7 @@ func (c *Client) DeleteRecord(domain string, data Record) (*Message, error) { return nil, fmt.Errorf("error: status code %d", resp.StatusCode) } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read body: %w", err) } diff --git a/providers/dns/servercow/internal/client_test.go b/providers/dns/servercow/internal/client_test.go index 1745cf67..f44082d9 100644 --- a/providers/dns/servercow/internal/client_test.go +++ b/providers/dns/servercow/internal/client_test.go @@ -3,7 +3,6 @@ package internal import ( "encoding/json" "io" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -53,7 +52,7 @@ func TestClient_GetRecords(t *testing.T) { recordsJSON, err := json.Marshal(records) require.NoError(t, err) - expectedContent, err := ioutil.ReadFile("./fixtures/records-01.json") + expectedContent, err := os.ReadFile("./fixtures/records-01.json") require.NoError(t, err) assert.JSONEq(t, string(expectedContent), string(recordsJSON)) @@ -92,7 +91,7 @@ func TestClient_CreateUpdateRecord(t *testing.T) { return } - content, err := ioutil.ReadAll(req.Body) + content, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusBadRequest) return @@ -163,7 +162,7 @@ func TestClient_DeleteRecord(t *testing.T) { return } - content, err := ioutil.ReadAll(req.Body) + content, err := io.ReadAll(req.Body) if err != nil { http.Error(rw, err.Error(), http.StatusBadRequest) return diff --git a/providers/dns/sonic/internal/client.go b/providers/dns/sonic/internal/client.go index ad809061..ba52411c 100644 --- a/providers/dns/sonic/internal/client.go +++ b/providers/dns/sonic/internal/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -81,7 +81,7 @@ func (c *Client) SetRecord(hostname string, value string, ttl int) error { defer func() { _ = resp.Body.Close() }() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read response body: %w", err) } diff --git a/providers/dns/stackpath/client.go b/providers/dns/stackpath/client.go index 9759fa03..e1290f84 100644 --- a/providers/dns/stackpath/client.go +++ b/providers/dns/stackpath/client.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "path" @@ -209,7 +209,7 @@ func readBody(resp *http.Response) ([]byte, error) { defer resp.Body.Close() - rawBody, err := ioutil.ReadAll(resp.Body) + rawBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/versio/client.go b/providers/dns/versio/client.go index 6f70c803..7fd7e75f 100644 --- a/providers/dns/versio/client.go +++ b/providers/dns/versio/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "path" ) @@ -99,7 +98,7 @@ func (d *DNSProvider) do(req *http.Request, result interface{}) error { if resp.StatusCode >= http.StatusBadRequest { var body []byte - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err) } @@ -113,7 +112,7 @@ func (d *DNSProvider) do(req *http.Request, result interface{}) error { } if result != nil { - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("request failed: %w", err) } diff --git a/providers/dns/vinyldns/mock_test.go b/providers/dns/vinyldns/mock_test.go index 836d2e62..b7f1e241 100644 --- a/providers/dns/vinyldns/mock_test.go +++ b/providers/dns/vinyldns/mock_test.go @@ -2,9 +2,9 @@ package vinyldns import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "sync" "testing" @@ -102,7 +102,7 @@ func (h *mockRouter) add(method, path string, statusCode int, filename string) { h.routes[method][path] = func(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(statusCode) - data, err := ioutil.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) + data, err := os.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return diff --git a/providers/dns/wedos/internal/client.go b/providers/dns/wedos/internal/client.go index 70d486ef..2d0f94ac 100644 --- a/providers/dns/wedos/internal/client.go +++ b/providers/dns/wedos/internal/client.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -196,7 +196,7 @@ func (c *Client) do(ctx context.Context, command string, payload interface{}) (* return nil, err } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/providers/dns/wedos/internal/client_test.go b/providers/dns/wedos/internal/client_test.go index ac92e1ea..30c7d486 100644 --- a/providers/dns/wedos/internal/client_test.go +++ b/providers/dns/wedos/internal/client_test.go @@ -3,9 +3,9 @@ package internal import ( "context" "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "regexp" "testing" @@ -38,7 +38,7 @@ func setupNew(t *testing.T, expectedForm string, filename string) *Client { return } - data, err := ioutil.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) + data, err := os.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return diff --git a/providers/dns/zoneee/client.go b/providers/dns/zoneee/client.go index 4266629b..c7c2a6da 100644 --- a/providers/dns/zoneee/client.go +++ b/providers/dns/zoneee/client.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "path" ) @@ -100,7 +99,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error { return nil } - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return err } @@ -123,7 +122,7 @@ func checkResponse(resp *http.Response) error { defer resp.Body.Close() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) } diff --git a/providers/http/webroot/webroot.go b/providers/http/webroot/webroot.go index c9e4fed7..a135d0ad 100644 --- a/providers/http/webroot/webroot.go +++ b/providers/http/webroot/webroot.go @@ -4,7 +4,6 @@ package webroot import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" @@ -35,7 +34,7 @@ func (w *HTTPProvider) Present(domain, token, keyAuth string) error { return fmt.Errorf("could not create required directories in webroot for HTTP challenge: %w", err) } - err = ioutil.WriteFile(challengeFilePath, []byte(keyAuth), 0o644) + err = os.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 09f674cb..124b324a 100644 --- a/providers/http/webroot/webroot_test.go +++ b/providers/http/webroot/webroot_test.go @@ -1,7 +1,6 @@ package webroot import ( - "io/ioutil" "os" "testing" @@ -30,7 +29,7 @@ func TestHTTPProvider(t *testing.T) { } var data []byte - data, err = ioutil.ReadFile(challengeFilePath) + data, err = os.ReadFile(challengeFilePath) require.NoError(t, err) dataStr := string(data)