Merge pull request #117468 from HirazawaUi/replace-test-deprecated-ioutil

Replace the deprecated ioutil methods in the test directory
This commit is contained in:
Kubernetes Prow Robot 2023-05-03 12:02:32 -07:00 committed by GitHub
commit fb93000eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 6 deletions

View File

@ -20,7 +20,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"time" "time"
@ -46,7 +45,7 @@ func getCredentials(tokenEndpoint string, r io.Reader, w io.Writer) error {
tokenEndpoint: tokenEndpoint, tokenEndpoint: tokenEndpoint,
} }
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

View File

@ -22,7 +22,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
credentialproviderv1 "k8s.io/kubelet/pkg/apis/credentialprovider/v1" credentialproviderv1 "k8s.io/kubelet/pkg/apis/credentialprovider/v1"
@ -108,7 +107,7 @@ func readURL(url string, client *http.Client) (body []byte, err error) {
} }
limitedReader := &io.LimitedReader{R: resp.Body, N: maxReadLength} limitedReader := &io.LimitedReader{R: resp.Body, N: maxReadLength}
contents, err := ioutil.ReadAll(limitedReader) contents, err := io.ReadAll(limitedReader)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -22,7 +22,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math" "math"
"os" "os"
"path" "path"
@ -602,7 +601,7 @@ func initTestOutput(tb testing.TB) io.Writer {
if err := fileOutput.Close(); err != nil { if err := fileOutput.Close(); err != nil {
tb.Fatalf("close log file: %v", err) tb.Fatalf("close log file: %v", err)
} }
log, err := ioutil.ReadFile(logfileName) log, err := os.ReadFile(logfileName)
if err != nil { if err != nil {
tb.Fatalf("read log file: %v", err) tb.Fatalf("read log file: %v", err)
} }