diff --git a/cmd/check/main.go b/cmd/check/main.go index e4abb2af..7b9c709c 100644 --- a/cmd/check/main.go +++ b/cmd/check/main.go @@ -5,7 +5,7 @@ import ( "crypto/x509" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "net/http" "net/url" @@ -163,7 +163,7 @@ func fetchDigest(client *http.Client, manifestURL, repository, tag string) (stri ctHeader := manifestResponse.Header.Get("Content-Type") - bytes, err := ioutil.ReadAll(manifestResponse.Body) + bytes, err := io.ReadAll(manifestResponse.Body) fatalIf("failed to read response body", err) _, desc, err := distribution.UnmarshalManifest(ctHeader, bytes) diff --git a/cmd/print-metadata/main_test.go b/cmd/print-metadata/main_test.go index 4edb1429..64459dbe 100644 --- a/cmd/print-metadata/main_test.go +++ b/cmd/print-metadata/main_test.go @@ -3,7 +3,6 @@ package main_test import ( "encoding/json" "fmt" - "io/ioutil" "os" "os/exec" "runtime" @@ -41,7 +40,7 @@ var _ = Describe("print-metadata", func() { Context("when user file exists", func() { BeforeEach(func() { var err error - userFile, err = ioutil.TempFile("", "print-metadata-test") + userFile, err = os.CreateTemp("", "print-metadata-test") Expect(err).NotTo(HaveOccurred()) cmd = exec.Command(printMetadataPath, "-userFile", userFile.Name()) diff --git a/cmd/print-metadata/passwd/passwd_test.go b/cmd/print-metadata/passwd/passwd_test.go index 4116bea5..2ca17561 100644 --- a/cmd/print-metadata/passwd/passwd_test.go +++ b/cmd/print-metadata/passwd/passwd_test.go @@ -2,7 +2,6 @@ package passwd_test import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -26,7 +25,7 @@ var _ = Describe("Passwd", func() { }) JustBeforeEach(func() { - path, err := ioutil.TempDir("", "passwd") + path, err := os.MkdirTemp("", "passwd") Expect(err).ToNot(HaveOccurred()) etcPasswdDir = path @@ -36,7 +35,7 @@ var _ = Describe("Passwd", func() { etcPasswdContents += fmt.Sprintf("%s:*:%d:1:User Name:/dev/null:/usr/bin/false\n", user.Username, user.ID) } - err = ioutil.WriteFile(etcPasswdPath, []byte(etcPasswdContents), 0600) + err = os.WriteFile(etcPasswdPath, []byte(etcPasswdContents), 0600) Expect(err).ToNot(HaveOccurred()) }) diff --git a/tests/out_test.go b/tests/out_test.go index e57cada4..802df105 100644 --- a/tests/out_test.go +++ b/tests/out_test.go @@ -3,7 +3,6 @@ package docker_image_resource_test import ( "bytes" "fmt" - "io/ioutil" "os/exec" "encoding/json" @@ -529,22 +528,22 @@ var _ = Describe("Out", func() { BeforeEach(func() { os.Mkdir("/tmp/expected_base_1", os.ModeDir) // this image should really be an actual tarball, but the test passes with text. :shrug: - ioutil.WriteFile("/tmp/expected_base_1/image", []byte("some-image-1"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_1/repository", []byte("some-repository-1"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_1/image-id", []byte("some-image-id-1"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_1/tag", []byte("some-tag-1"), os.ModePerm) + os.WriteFile("/tmp/expected_base_1/image", []byte("some-image-1"), os.ModePerm) + os.WriteFile("/tmp/expected_base_1/repository", []byte("some-repository-1"), os.ModePerm) + os.WriteFile("/tmp/expected_base_1/image-id", []byte("some-image-id-1"), os.ModePerm) + os.WriteFile("/tmp/expected_base_1/tag", []byte("some-tag-1"), os.ModePerm) os.Mkdir("/tmp/expected_base_2", os.ModeDir) - ioutil.WriteFile("/tmp/expected_base_2/image", []byte("some-image-2"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_2/repository", []byte("some-repository-2"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_2/image-id", []byte("some-image-id-2"), os.ModePerm) - ioutil.WriteFile("/tmp/expected_base_2/tag", []byte("some-tag-2"), os.ModePerm) + os.WriteFile("/tmp/expected_base_2/image", []byte("some-image-2"), os.ModePerm) + os.WriteFile("/tmp/expected_base_2/repository", []byte("some-repository-2"), os.ModePerm) + os.WriteFile("/tmp/expected_base_2/image-id", []byte("some-image-id-2"), os.ModePerm) + os.WriteFile("/tmp/expected_base_2/tag", []byte("some-tag-2"), os.ModePerm) os.Mkdir("/tmp/unexpected_base", os.ModeDir) - ioutil.WriteFile("/tmp/unexpected_base/image", []byte("some-image-3"), os.ModePerm) - ioutil.WriteFile("/tmp/unexpected_base/repository", []byte("some-repository-3"), os.ModePerm) - ioutil.WriteFile("/tmp/unexpected_base/image-id", []byte("some-image-id-3"), os.ModePerm) - ioutil.WriteFile("/tmp/unexpected_base/tag", []byte("some-tag-3"), os.ModePerm) + os.WriteFile("/tmp/unexpected_base/image", []byte("some-image-3"), os.ModePerm) + os.WriteFile("/tmp/unexpected_base/repository", []byte("some-repository-3"), os.ModePerm) + os.WriteFile("/tmp/unexpected_base/image-id", []byte("some-image-id-3"), os.ModePerm) + os.WriteFile("/tmp/unexpected_base/tag", []byte("some-tag-3"), os.ModePerm) }) AfterEach(func() { @@ -612,16 +611,16 @@ var _ = Describe("Out", func() { BeforeEach(func() { os.Mkdir("/tmp/cache_from_1", os.ModeDir) // this image should really be an actual tarball, but the test passes with text. :shrug: - ioutil.WriteFile("/tmp/cache_from_1/image", []byte("some-image-1"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_1/repository", []byte("some-repository-1"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_1/image-id", []byte("some-image-id-1"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_1/tag", []byte("some-tag-1"), os.ModePerm) + os.WriteFile("/tmp/cache_from_1/image", []byte("some-image-1"), os.ModePerm) + os.WriteFile("/tmp/cache_from_1/repository", []byte("some-repository-1"), os.ModePerm) + os.WriteFile("/tmp/cache_from_1/image-id", []byte("some-image-id-1"), os.ModePerm) + os.WriteFile("/tmp/cache_from_1/tag", []byte("some-tag-1"), os.ModePerm) os.Mkdir("/tmp/cache_from_2", os.ModeDir) - ioutil.WriteFile("/tmp/cache_from_2/image", []byte("some-image-2"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_2/repository", []byte("some-repository-2"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_2/image-id", []byte("some-image-id-2"), os.ModePerm) - ioutil.WriteFile("/tmp/cache_from_2/tag", []byte("some-tag-2"), os.ModePerm) + os.WriteFile("/tmp/cache_from_2/image", []byte("some-image-2"), os.ModePerm) + os.WriteFile("/tmp/cache_from_2/repository", []byte("some-repository-2"), os.ModePerm) + os.WriteFile("/tmp/cache_from_2/image-id", []byte("some-image-id-2"), os.ModePerm) + os.WriteFile("/tmp/cache_from_2/tag", []byte("some-tag-2"), os.ModePerm) }) AfterEach(func() {