chore: update Go (#1469)
This commit is contained in:
parent
bc8ff4a192
commit
dc2b19e1b1
98 changed files with 210 additions and 243 deletions
2
.github/workflows/go-cross.yml
vendored
2
.github/workflows/go-cross.yml
vendored
|
@ -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:
|
||||
|
|
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
|
@ -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
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
"noctx",
|
||||
"forcetypeassert",
|
||||
"tagliatelle",
|
||||
"errname",
|
||||
]
|
||||
|
||||
[issues]
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
2
go.mod
2
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.
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
|
|
3
platform/config/env/env.go
vendored
3
platform/config/env/env.go
vendored
|
@ -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 ""
|
||||
|
|
4
platform/config/env/env_test.go
vendored
4
platform/config/env/env_test.go
vendored
|
@ -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())
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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]`))
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue