replace deprecated io/ioutil

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-11-02 22:55:22 +01:00
parent e3509fc1de
commit f8b3af78fc
33 changed files with 113 additions and 202 deletions

View File

@@ -7,8 +7,8 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
"time"
@@ -89,7 +89,7 @@ func newCloudFrontStorageMiddleware(storageDriver storagedriver.StorageDriver, o
}
// get urlSigner from the file specified in pkPath
pkBytes, err := ioutil.ReadFile(pkPath)
pkBytes, err := os.ReadFile(pkPath)
if err != nil {
return nil, fmt.Errorf("failed to read privatekey file: %s", err)
}

View File

@@ -1,7 +1,6 @@
package middleware
import (
"io/ioutil"
"os"
"testing"
@@ -41,7 +40,7 @@ pZeMRablbPQdp8/1NyIwimq1VlG0ohQ4P6qhW7E09ZMC
-----END RSA PRIVATE KEY-----
`
file, err := ioutil.TempFile("", "pkey")
file, err := os.CreateTemp("", "pkey")
if err != nil {
t.Fatal("File cannot be created")
}

View File

@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"strings"
@@ -68,7 +68,7 @@ func fetchAWSIPs(url string) (awsIPResponse, error) {
return response, err
}
if resp.StatusCode != 200 {
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
return response, fmt.Errorf("failed to fetch network data. response = %s", body)
}
decoder := json.NewDecoder(resp.Body)