diff --git a/staging/src/k8s.io/component-base/config/testing/helpers.go b/staging/src/k8s.io/component-base/config/testing/helpers.go index f7185835d46..8f1fcc8fb9b 100644 --- a/staging/src/k8s.io/component-base/config/testing/helpers.go +++ b/staging/src/k8s.io/component-base/config/testing/helpers.go @@ -19,7 +19,6 @@ package testing import ( "bytes" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -47,7 +46,7 @@ func RunTestsOnYAMLData(t *testing.T, tests []TestCase) { } func decodeYAML(t *testing.T, path string, codec runtime.Codec) runtime.Object { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { t.Fatal(err) } @@ -72,7 +71,7 @@ func getCodecForGV(codecs serializer.CodecFactory, gv schema.GroupVersion) (runt } func matchOutputFile(t *testing.T, actual []byte, expectedFilePath string) { - expected, err := ioutil.ReadFile(expectedFilePath) + expected, err := os.ReadFile(expectedFilePath) if err != nil && !os.IsNotExist(err) { t.Fatalf("couldn't read test data: %v", err) } @@ -97,7 +96,7 @@ func matchOutputFile(t *testing.T, actual []byte, expectedFilePath string) { if err := os.MkdirAll(filepath.Dir(expectedFilePath), 0755); err != nil { t.Fatal(err) } - if err := ioutil.WriteFile(expectedFilePath, actual, 0644); err != nil { + if err := os.WriteFile(expectedFilePath, actual, 0644); err != nil { t.Fatal(err) } t.Error("wrote expected test data... verify, commit, and rerun tests") diff --git a/staging/src/k8s.io/component-base/config/testing/roundtrip.go b/staging/src/k8s.io/component-base/config/testing/roundtrip.go index 1233349384b..b40efee82e0 100644 --- a/staging/src/k8s.io/component-base/config/testing/roundtrip.go +++ b/staging/src/k8s.io/component-base/config/testing/roundtrip.go @@ -18,7 +18,7 @@ package testing import ( "fmt" - "io/ioutil" + "os" "path/filepath" "testing" @@ -47,7 +47,7 @@ func GetRoundtripTestCases(t *testing.T, scheme *runtime.Scheme, codecs serializ for gk, versions := range versionsForKind { testdir := filepath.Join("testdata", gk.Kind, "roundtrip") - dirs, err := ioutil.ReadDir(testdir) + dirs, err := os.ReadDir(testdir) if err != nil { t.Fatalf("failed to read testdir %s: %v", testdir, err) } diff --git a/staging/src/k8s.io/component-base/configz/configz_test.go b/staging/src/k8s.io/component-base/configz/configz_test.go index 850739df2e0..c975aad6cd2 100644 --- a/staging/src/k8s.io/component-base/configz/configz_test.go +++ b/staging/src/k8s.io/component-base/configz/configz_test.go @@ -17,7 +17,7 @@ limitations under the License. package configz import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -39,7 +39,7 @@ func TestConfigz(t *testing.T) { t.Fatalf("err: %v", err) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("err: %v", err) } @@ -53,7 +53,7 @@ func TestConfigz(t *testing.T) { t.Fatalf("err: %v", err) } - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { t.Fatalf("err: %v", err) } @@ -67,7 +67,7 @@ func TestConfigz(t *testing.T) { t.Fatalf("err: %v", err) } - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { t.Fatalf("err: %v", err) } diff --git a/staging/src/k8s.io/component-base/metrics/http_test.go b/staging/src/k8s.io/component-base/metrics/http_test.go index d393b352f39..fe4a50ea2d5 100644 --- a/staging/src/k8s.io/component-base/metrics/http_test.go +++ b/staging/src/k8s.io/component-base/metrics/http_test.go @@ -17,7 +17,7 @@ limitations under the License. package metrics import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -57,7 +57,7 @@ func TestResetHandler(t *testing.T) { } rec := httptest.NewRecorder() resetHandler.ServeHTTP(rec, req) - body, err := ioutil.ReadAll(rec.Result().Body) + body, err := io.ReadAll(rec.Result().Body) if err != nil { t.Fatalf("Error reading response body") }