diff options
Diffstat (limited to 'test/e2e')
42 files changed, 169 insertions, 210 deletions
diff --git a/test/e2e/benchmarks_test.go b/test/e2e/benchmarks_test.go index d1332665a..6773eae02 100644 --- a/test/e2e/benchmarks_test.go +++ b/test/e2e/benchmarks_test.go @@ -5,7 +5,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path" "strconv" @@ -108,7 +107,7 @@ var _ = Describe("Podman Benchmark Suite", func() { if f.IsDir() { continue } - raw, err := ioutil.ReadFile(path.Join(timedir, f.Name())) + raw, err := os.ReadFile(path.Join(timedir, f.Name())) if err != nil { Fail(fmt.Sprintf("Error reading timing file: %v", err)) } diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 424c7244e..0f6cb2a10 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -3,7 +3,6 @@ package integration import ( "bytes" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -219,10 +218,10 @@ var _ = Describe("Podman build", func() { } fakeFile := filepath.Join(os.TempDir(), "Containerfile") - Expect(ioutil.WriteFile(fakeFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) + Expect(os.WriteFile(fakeFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) targetFile := filepath.Join(targetPath, "Containerfile") - Expect(ioutil.WriteFile(targetFile, []byte("FROM scratch"), 0755)).To(BeNil()) + Expect(os.WriteFile(targetFile, []byte("FROM scratch"), 0755)).To(BeNil()) defer func() { Expect(os.RemoveAll(fakeFile)).To(BeNil()) @@ -257,7 +256,7 @@ var _ = Describe("Podman build", func() { session := podmanTest.Podman([]string{"build", "--pull-never", "build/basicalpine", "--iidfile", targetFile}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - id, _ := ioutil.ReadFile(targetFile) + id, _ := os.ReadFile(targetFile) // Verify that id is correct inspect := podmanTest.Podman([]string{"inspect", string(id)}) @@ -311,7 +310,7 @@ var _ = Describe("Podman build", func() { RUN printenv http_proxy`, ALPINE) dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") - err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755) + err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) @@ -330,7 +329,7 @@ RUN printenv http_proxy`, ALPINE) RUN exit 5`, ALPINE) dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") - err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755) + err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "-t", "error-test", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) @@ -388,7 +387,7 @@ RUN exit 5`, ALPINE) err = os.Mkdir(targetSubPath, 0755) Expect(err).To(BeNil()) dummyFile := filepath.Join(targetSubPath, "dummy") - err = ioutil.WriteFile(dummyFile, []byte("dummy"), 0644) + err = os.WriteFile(dummyFile, []byte("dummy"), 0644) Expect(err).To(BeNil()) containerfile := fmt.Sprintf(`FROM %s @@ -396,7 +395,7 @@ ADD . /test RUN find /test`, ALPINE) containerfilePath := filepath.Join(targetPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) defer func() { @@ -437,7 +436,7 @@ RUN find /test`, ALPINE) containerfile := fmt.Sprintf("FROM %s", ALPINE) containerfilePath := filepath.Join(targetSubPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) defer func() { @@ -476,7 +475,7 @@ ADD . /testfilter/ RUN find /testfilter/`, ALPINE) containerfilePath := filepath.Join(targetPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) targetSubPath := filepath.Join(targetPath, "subdir") @@ -484,15 +483,15 @@ RUN find /testfilter/`, ALPINE) Expect(err).To(BeNil()) dummyFile1 := filepath.Join(targetPath, "dummy1") - err = ioutil.WriteFile(dummyFile1, []byte("dummy1"), 0644) + err = os.WriteFile(dummyFile1, []byte("dummy1"), 0644) Expect(err).To(BeNil()) dummyFile2 := filepath.Join(targetPath, "dummy2") - err = ioutil.WriteFile(dummyFile2, []byte("dummy2"), 0644) + err = os.WriteFile(dummyFile2, []byte("dummy2"), 0644) Expect(err).To(BeNil()) dummyFile3 := filepath.Join(targetSubPath, "dummy3") - err = ioutil.WriteFile(dummyFile3, []byte("dummy3"), 0644) + err = os.WriteFile(dummyFile3, []byte("dummy3"), 0644) Expect(err).To(BeNil()) defer func() { @@ -509,7 +508,7 @@ subdir**` // test .dockerignore By("Test .dockererignore") - err = ioutil.WriteFile(dockerignoreFile, []byte(dockerignoreContent), 0644) + err = os.WriteFile(dockerignoreFile, []byte(dockerignoreContent), 0644) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "-t", "test", "."}) @@ -540,18 +539,18 @@ subdir**` contents.WriteString("RUN find /testfilter/ -print\n") containerfile := filepath.Join(tempdir, "Containerfile") - Expect(ioutil.WriteFile(containerfile, contents.Bytes(), 0644)).ToNot(HaveOccurred()) + Expect(os.WriteFile(containerfile, contents.Bytes(), 0644)).ToNot(HaveOccurred()) contextDir, err := CreateTempDirInTempDir() Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(contextDir) - Expect(ioutil.WriteFile(filepath.Join(contextDir, "expected"), contents.Bytes(), 0644)). + Expect(os.WriteFile(filepath.Join(contextDir, "expected"), contents.Bytes(), 0644)). ToNot(HaveOccurred()) subdirPath := filepath.Join(contextDir, "subdir") Expect(os.MkdirAll(subdirPath, 0755)).ToNot(HaveOccurred()) - Expect(ioutil.WriteFile(filepath.Join(subdirPath, "extra"), contents.Bytes(), 0644)). + Expect(os.WriteFile(filepath.Join(subdirPath, "extra"), contents.Bytes(), 0644)). ToNot(HaveOccurred()) randomFile := filepath.Join(subdirPath, "randomFile") dd := exec.Command("dd", "if=/dev/urandom", "of="+randomFile, "bs=1G", "count=1") @@ -567,7 +566,7 @@ subdir**` }() By("Test .containerignore filtering subdirectory") - err = ioutil.WriteFile(filepath.Join(contextDir, ".containerignore"), []byte(`subdir/`), 0644) + err = os.WriteFile(filepath.Join(contextDir, ".containerignore"), []byte(`subdir/`), 0644) Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"build", "-f", containerfile, contextDir}) @@ -597,7 +596,7 @@ subdir**` err = os.Mkdir(targetSubPath, 0755) Expect(err).To(BeNil()) dummyFile := filepath.Join(targetSubPath, "dummy") - err = ioutil.WriteFile(dummyFile, []byte("dummy"), 0644) + err = os.WriteFile(dummyFile, []byte("dummy"), 0644) Expect(err).To(BeNil()) emptyDir := filepath.Join(targetSubPath, "emptyDir") @@ -612,7 +611,7 @@ RUN find /test RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`, ALPINE) containerfilePath := filepath.Join(targetSubPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) defer func() { @@ -641,7 +640,7 @@ RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`, ALPINE) RUN cat /etc/hosts RUN grep CapEff /proc/self/status` - Expect(ioutil.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) + Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) defer func() { Expect(os.RemoveAll(containerFile)).To(BeNil()) @@ -668,7 +667,7 @@ RUN grep CapEff /proc/self/status` Expect(err).To(BeNil()) containerFile := filepath.Join(targetPath, "Containerfile") - Expect(ioutil.WriteFile(containerFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) + Expect(os.WriteFile(containerFile, []byte(fmt.Sprintf("FROM %s", ALPINE)), 0755)).To(BeNil()) defer func() { Expect(os.RemoveAll(containerFile)).To(BeNil()) @@ -712,7 +711,7 @@ RUN grep CapEff /proc/self/status` RUN echo hello`, ALPINE) containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--timestamp", "0", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -730,7 +729,7 @@ RUN echo hello`, ALPINE) containerFile := filepath.Join(targetPath, "Containerfile") content := `FROM scratch` - Expect(ioutil.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) + Expect(os.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) session := podmanTest.Podman([]string{"build", "--log-rusage", "--pull-never", targetPath}) session.WaitWithDefaultTimeout() @@ -743,7 +742,7 @@ RUN echo hello`, ALPINE) It("podman build --arch --os flag", func() { containerfile := `FROM scratch` containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--arch", "foo", "--os", "bar", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -762,7 +761,7 @@ RUN echo hello`, ALPINE) It("podman build --os windows flag", func() { containerfile := `FROM scratch` containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--os", "windows", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -785,7 +784,7 @@ RUN echo hello`, ALPINE) containerfile := fmt.Sprintf(`FROM %s RUN ls /dev/fuse`, ALPINE) containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -801,7 +800,7 @@ RUN ls /dev/fuse`, ALPINE) containerfile := fmt.Sprintf(`FROM %s RUN ls /dev/test1`, ALPINE) containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -822,7 +821,7 @@ RUN ls /dev/test1`, ALPINE) Expect(err).To(BeNil()) err = os.Mkdir(buildRoot, 0755) Expect(err).To(BeNil()) - err = ioutil.WriteFile(containerFilePath, []byte(containerFile), 0755) + err = os.WriteFile(containerFilePath, []byte(containerFile), 0755) Expect(err).To(BeNil()) build := podmanTest.Podman([]string{"build", "-f", containerFilePath, buildRoot}) build.WaitWithDefaultTimeout() diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 452a378c2..14814628d 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -287,7 +286,7 @@ var _ = Describe("Podman commit", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - id, _ := ioutil.ReadFile(targetFile) + id, _ := os.ReadFile(targetFile) check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() @@ -297,7 +296,7 @@ var _ = Describe("Podman commit", func() { It("podman commit should not commit secret", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -322,7 +321,7 @@ var _ = Describe("Podman commit", func() { It("podman commit should not commit env secret", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 690e2f22c..67a889b25 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "math/rand" "net" "net/url" @@ -144,7 +143,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { } f.Close() } - path, err := ioutil.TempDir("", "libpodlock") + path, err := os.MkdirTemp("", "libpodlock") if err != nil { fmt.Println(err) os.Exit(1) @@ -875,7 +874,7 @@ func writeConf(conf []byte, confPath string) { fmt.Println(err) } } - if err := ioutil.WriteFile(confPath, conf, 0o777); err != nil { + if err := os.WriteFile(confPath, conf, 0o777); err != nil { fmt.Println(err) } } @@ -967,7 +966,7 @@ func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) { func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers string, label string) string { dockerfilePath := filepath.Join(p.TempDir, "Dockerfile") - err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755) + err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0755) Expect(err).To(BeNil()) cmd := []string{"build", "--pull-never", "--layers=" + layers, "--file", dockerfilePath} if label != "" { diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go index 3c54691aa..6d6173d0f 100644 --- a/test/e2e/container_create_volume_test.go +++ b/test/e2e/container_create_volume_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -15,7 +14,7 @@ import ( func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string) { // Create a dummy file for data volume dummyFile := filepath.Join(pTest.TempDir, data) - err := ioutil.WriteFile(dummyFile, []byte(data), 0644) + err := os.WriteFile(dummyFile, []byte(data), 0644) Expect(err).To(BeNil()) // Create a data volume container image but no CMD binary in it @@ -29,7 +28,7 @@ VOLUME %s/`, data, dest, dest) func createContainersConfFile(pTest *PodmanTestIntegration) { configPath := filepath.Join(pTest.TempDir, "containers.conf") containersConf := []byte("[containers]\nprepare_volume_on_create = true\n") - err := ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err := os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).To(BeNil()) // Set custom containers.conf file diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 41e78ce0e..211f6b572 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -208,7 +207,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { tempdir, err = CreateTempDirInTempDir() Expect(err).ToNot(HaveOccurred()) - err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[containers]\nvolumes=[\"%s:%s:Z\",]\n", tempdir, tempdir)), 0755) + err := os.WriteFile(conffile, []byte(fmt.Sprintf("[containers]\nvolumes=[\"%s:%s:Z\",]\n", tempdir, tempdir)), 0755) Expect(err).ToNot(HaveOccurred()) os.Setenv("CONTAINERS_CONF", conffile) @@ -406,7 +405,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { profile := filepath.Join(podmanTest.TempDir, "seccomp.json") containersConf := []byte(fmt.Sprintf("[containers]\nseccomp_profile=\"%s\"", profile)) - err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err = os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) if IsRemote() { @@ -430,7 +429,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { os.Setenv("CONTAINERS_CONF", configPath) containersConf := []byte("[engine]\nimage_copy_tmp_dir=\"/foobar\"") - err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err = os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) if IsRemote() { @@ -443,7 +442,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { Expect(session.OutputToString()).To(Equal("/foobar")) containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=%q", storagePath)) - err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err = os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) if IsRemote() { podmanTest.RestartRemoteService() @@ -455,7 +454,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { Expect(session.Out.Contents()).To(ContainSubstring(storagePath)) containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"") - err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err = os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) if !IsRemote() { @@ -485,7 +484,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { os.Setenv("CONTAINERS_CONF", configPath) containersConf := []byte("[engine]\ninfra_image=\"" + infra1 + "\"") - err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + err = os.WriteFile(configPath, containersConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) if IsRemote() { @@ -520,7 +519,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { os.Setenv("CONTAINERS_CONF", configPath) defer os.Remove(configPath) - err := ioutil.WriteFile(configPath, []byte("[engine]\nremote=true"), os.ModePerm) + err := os.WriteFile(configPath, []byte("[engine]\nremote=true"), os.ModePerm) Expect(err).ToNot(HaveOccurred()) // podmanTest.Podman() cannot be used as it was initialized remote==false @@ -540,7 +539,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { } conffile := filepath.Join(podmanTest.TempDir, "container.conf") - err := ioutil.WriteFile(conffile, []byte("[containers]\ncgroups=\"disabled\"\n"), 0755) + err := os.WriteFile(conffile, []byte("[containers]\ncgroups=\"disabled\"\n"), 0755) Expect(err).ToNot(HaveOccurred()) result := podmanTest.Podman([]string{"create", ALPINE, "true"}) @@ -572,7 +571,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { It("podman containers.conf runtime", func() { SkipIfRemote("--runtime option is not available for remote commands") conffile := filepath.Join(podmanTest.TempDir, "container.conf") - err := ioutil.WriteFile(conffile, []byte("[engine]\nruntime=\"testruntime\"\n"), 0755) + err := os.WriteFile(conffile, []byte("[engine]\nruntime=\"testruntime\"\n"), 0755) Expect(err).ToNot(HaveOccurred()) os.Setenv("CONTAINERS_CONF", conffile) diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 8a65b85d3..214903a16 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "os/exec" "os/user" @@ -43,13 +42,13 @@ var _ = Describe("Podman cp", func() { // Copy a file to the container, then back to the host and make sure // that the contents match. It("podman cp file", func() { - srcFile, err := ioutil.TempFile("", "") + srcFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer srcFile.Close() defer os.Remove(srcFile.Name()) originalContent := []byte("podman cp file test") - err = ioutil.WriteFile(srcFile.Name(), originalContent, 0644) + err = os.WriteFile(srcFile.Name(), originalContent, 0644) Expect(err).To(BeNil()) // Create a container. NOTE that container mustn't be running for copying. @@ -72,7 +71,7 @@ var _ = Describe("Podman cp", func() { // Copy FROM the container. - destFile, err := ioutil.TempFile("", "") + destFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer destFile.Close() defer os.Remove(destFile.Name()) @@ -86,7 +85,7 @@ var _ = Describe("Podman cp", func() { Expect(session).Should(Exit(0)) // Now make sure the content matches. - roundtripContent, err := ioutil.ReadFile(destFile.Name()) + roundtripContent, err := os.ReadFile(destFile.Name()) Expect(err).To(BeNil()) Expect(roundtripContent).To(Equal(originalContent)) }) @@ -94,13 +93,13 @@ var _ = Describe("Podman cp", func() { // Copy a file to the container, then back to the host in --pid=host It("podman cp --pid=host file", func() { SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") - srcFile, err := ioutil.TempFile("", "") + srcFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer srcFile.Close() defer os.Remove(srcFile.Name()) originalContent := []byte("podman cp file test") - err = ioutil.WriteFile(srcFile.Name(), originalContent, 0644) + err = os.WriteFile(srcFile.Name(), originalContent, 0644) Expect(err).To(BeNil()) // Create a container. NOTE that container mustn't be running for copying. @@ -120,7 +119,7 @@ var _ = Describe("Podman cp", func() { // Copy FROM the container. - destFile, err := ioutil.TempFile("", "") + destFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer destFile.Close() defer os.Remove(destFile.Name()) @@ -130,7 +129,7 @@ var _ = Describe("Podman cp", func() { Expect(session).Should(Exit(0)) // Now make sure the content matches. - roundtripContent, err := ioutil.ReadFile(destFile.Name()) + roundtripContent, err := os.ReadFile(destFile.Name()) Expect(err).To(BeNil()) Expect(roundtripContent).To(Equal(originalContent)) }) @@ -139,13 +138,13 @@ var _ = Describe("Podman cp", func() { // make sure that the link and the resolved path are accessible and // give the right content. It("podman cp symlink", func() { - srcFile, err := ioutil.TempFile("", "") + srcFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer srcFile.Close() defer os.Remove(srcFile.Name()) originalContent := []byte("podman cp symlink test") - err = ioutil.WriteFile(srcFile.Name(), originalContent, 0644) + err = os.WriteFile(srcFile.Name(), originalContent, 0644) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"}) @@ -178,13 +177,13 @@ var _ = Describe("Podman cp", func() { // the path to the volume's mount point on the host, and 3) copy the // data to the volume and not the container. It("podman cp volume", func() { - srcFile, err := ioutil.TempFile("", "") + srcFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer srcFile.Close() defer os.Remove(srcFile.Name()) originalContent := []byte("podman cp volume") - err = ioutil.WriteFile(srcFile.Name(), originalContent, 0644) + err = os.WriteFile(srcFile.Name(), originalContent, 0644) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"volume", "create", "data"}) session.WaitWithDefaultTimeout() @@ -205,7 +204,7 @@ var _ = Describe("Podman cp", func() { Expect(session).Should(Exit(0)) volumeMountPoint := session.OutputToString() - copiedContent, err := ioutil.ReadFile(filepath.Join(volumeMountPoint, "file.txt")) + copiedContent, err := os.ReadFile(filepath.Join(volumeMountPoint, "file.txt")) Expect(err).To(BeNil()) Expect(copiedContent).To(Equal(originalContent)) }) @@ -214,7 +213,7 @@ var _ = Describe("Podman cp", func() { // it to the host and back to the container and make sure that we can // access it, and (roughly) the right users own it. It("podman cp from ctr chown ", func() { - srcFile, err := ioutil.TempFile("", "") + srcFile, err := os.CreateTemp("", "") Expect(err).To(BeNil()) defer srcFile.Close() defer os.Remove(srcFile.Name()) @@ -265,7 +264,7 @@ var _ = Describe("Podman cp", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) session = podmanTest.Podman([]string{"cp", container + ":/", tmpDir}) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index d5920dc3e..9a18dea18 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -242,7 +241,7 @@ var _ = Describe("Podman create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(125)) - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) defer os.RemoveAll(tmpDir) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index f4ee688b7..6bd13f7da 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -545,7 +544,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal) It("podman exec with env var secret", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index cd2378bdf..08eaa4dcf 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "os/user" "path/filepath" @@ -278,7 +277,7 @@ var _ = Describe("Podman generate kube", func() { if name == "root" { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -752,7 +751,7 @@ var _ = Describe("Podman generate kube", func() { kube.WaitWithDefaultTimeout() Expect(kube).Should(Exit(0)) - b, err := ioutil.ReadFile(outputFile) + b, err := os.ReadFile(outputFile) Expect(err).ShouldNot(HaveOccurred()) pod := new(v1.Pod) err = yaml.Unmarshal(b, pod) @@ -1045,7 +1044,7 @@ ENTRYPOINT ["sleep"]` targetPath, err := CreateTempDirInTempDir() Expect(err).To(BeNil()) containerfilePath := filepath.Join(targetPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) image := "generatekube:test" @@ -1135,7 +1134,7 @@ USER test1` targetPath, err := CreateTempDirInTempDir() Expect(err).To(BeNil()) containerfilePath := filepath.Join(targetPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) image := "generatekube:test" diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 347440faf..49d7a66f2 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "strings" @@ -539,7 +538,7 @@ var _ = Describe("Podman generate systemd", func() { }) It("podman generate systemd pod with containers --new", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "podID" defer os.RemoveAll(tmpDir) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 969f83b19..a84fd6538 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -303,7 +302,7 @@ var _ = Describe("Podman healthcheck run", func() { containerfile := fmt.Sprintf(`FROM %s HEALTHCHECK CMD ls -l / 2>&1`, ALPINE) containerfilePath := filepath.Join(targetPath, "Containerfile") - err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644) + err = os.WriteFile(containerfilePath, []byte(containerfile), 0644) Expect(err).To(BeNil()) defer func() { Expect(os.Chdir(cwd)).To(BeNil()) diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go index 2c275d974..3ee2b74b5 100644 --- a/test/e2e/image_scp_test.go +++ b/test/e2e/image_scp_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "path/filepath" @@ -25,7 +24,7 @@ var _ = Describe("podman image scp", func() { BeforeEach(func() { ConfPath.Value, ConfPath.IsSet = os.LookupEnv("CONTAINERS_CONF") - conf, err := ioutil.TempFile("", "containersconf") + conf, err := os.CreateTemp("", "containersconf") Expect(err).ToNot(HaveOccurred()) os.Setenv("CONTAINERS_CONF", conf.Name()) diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index 9d31deb55..ab4f607a0 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/exec" "os/user" @@ -104,7 +103,7 @@ var _ = Describe("Podman Info", func() { driver := `"overlay"` storageOpt := `"/usr/bin/fuse-overlayfs"` storageConf := []byte(fmt.Sprintf("[storage]\ndriver=%s\nrootless_storage_path=%s\n[storage.options]\nmount_program=%s", driver, rootlessStoragePath, storageOpt)) - err = ioutil.WriteFile(configPath, storageConf, os.ModePerm) + err = os.WriteFile(configPath, storageConf, os.ModePerm) Expect(err).To(BeNil()) u, err := user.Current() diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index 9b33e2f0d..30c82c45d 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" . "github.com/containers/podman/v4/test/utils" @@ -150,7 +149,7 @@ var _ = Describe("Podman kill", func() { }) It("podman kill --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "cid" defer os.RemoveAll(tmpDir) @@ -170,12 +169,12 @@ var _ = Describe("Podman kill", func() { }) It("podman kill multiple --cidfile", func() { - tmpDir1, err := ioutil.TempDir("", "") + tmpDir1, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile1 := tmpDir1 + "cid" defer os.RemoveAll(tmpDir1) - tmpDir2, err := ioutil.TempDir("", "") + tmpDir2, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile2 := tmpDir2 + "cid" defer os.RemoveAll(tmpDir2) diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 86be17eb3..499373e65 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -6,7 +6,6 @@ package integration import ( "errors" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -58,7 +57,7 @@ func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) { outfile := filepath.Join(p.TempDir, "registries.conf") os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile) - err := ioutil.WriteFile(outfile, b, 0644) + err := os.WriteFile(outfile, b, 0644) Expect(err).ToNot(HaveOccurred()) } diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index 60c53e27e..5951c1a3e 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -3,7 +3,6 @@ package integration import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -101,7 +100,7 @@ var _ = Describe("Podman login and logout", func() { }) readAuthInfo := func(filePath string) map[string]interface{} { - authBytes, err := ioutil.ReadFile(filePath) + authBytes, err := os.ReadFile(filePath) Expect(err).To(BeNil()) var authInfo map[string]interface{} @@ -137,12 +136,12 @@ var _ = Describe("Podman login and logout", func() { }) It("podman login and logout without registry parameter", func() { - registriesConf, err := ioutil.TempFile("", "TestLoginWithoutParameter") + registriesConf, err := os.CreateTemp("", "TestLoginWithoutParameter") Expect(err).To(BeNil()) defer registriesConf.Close() defer os.Remove(registriesConf.Name()) - err = ioutil.WriteFile(registriesConf.Name(), registriesConfWithSearch, os.ModePerm) + err = os.WriteFile(registriesConf.Name(), registriesConfWithSearch, os.ModePerm) Expect(err).To(BeNil()) // Environment is per-process, so this looks very unsafe; actually it seems fine because tests are not @@ -448,7 +447,7 @@ var _ = Describe("Podman login and logout", func() { It("podman login and logout with repository push with invalid auth.json credentials", func() { authFile := filepath.Join(podmanTest.TempDir, "auth.json") // only `server` contains the correct login data - err := ioutil.WriteFile(authFile, []byte(fmt.Sprintf(`{"auths": { + err := os.WriteFile(authFile, []byte(fmt.Sprintf(`{"auths": { "%s/podmantest": { "auth": "cG9kbWFudGVzdDp3cm9uZw==" }, "%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" } }}`, server, server)), 0644) @@ -494,7 +493,7 @@ var _ = Describe("Podman login and logout", func() { Expect(session).Should(Exit(0)) // only `server + /podmantest` and `server` have the correct login data - err := ioutil.WriteFile(authFile, []byte(fmt.Sprintf(`{"auths": { + err := os.WriteFile(authFile, []byte(fmt.Sprintf(`{"auths": { "%s/podmantest/test-alpine": { "auth": "cG9kbWFudGVzdDp3cm9uZw==" }, "%s/podmantest": { "auth": "cG9kbWFudGVzdDp0ZXN0" }, "%s": { "auth": "cG9kbWFudGVzdDp0ZXN0" } diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index e38499257..b0a5e7d03 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -338,7 +337,7 @@ var _ = Describe("Podman manifest", func() { for _, f := range blobs { blobPath := filepath.Join(blobsDir, f.Name()) - sourceFile, err := ioutil.ReadFile(blobPath) + sourceFile, err := os.ReadFile(blobPath) Expect(err).To(BeNil()) compressionType := archive.DetectCompression(sourceFile) diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index 363df2624..6500fc0e0 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -31,7 +30,7 @@ var _ = Describe("Podman pause", func() { } if CGROUPSV2 { - b, err := ioutil.ReadFile("/proc/self/cgroup") + b, err := os.ReadFile("/proc/self/cgroup") if err != nil { Skip("cannot read self cgroup") } @@ -336,7 +335,7 @@ var _ = Describe("Podman pause", func() { }) It("podman pause --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "cid" @@ -365,7 +364,7 @@ var _ = Describe("Podman pause", func() { }) It("podman pause multiple --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile1 := tmpDir + "cid-1" tmpFile2 := tmpDir + "cid-2" diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 26460c937..67c88953a 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "net" "net/url" "os" @@ -767,7 +766,7 @@ func generateMultiDocKubeYaml(kubeObjects []string, pathname string) error { func createSecret(podmanTest *PodmanTestIntegration, name string, value []byte) { //nolint:unparam secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, value, 0755) + err := os.WriteFile(secretFilePath, value, 0755) Expect(err).To(BeNil()) secret := podmanTest.Podman([]string{"secret", "create", name, secretFilePath}) @@ -1442,7 +1441,7 @@ var _ = Describe("Podman play kube", func() { conffile := filepath.Join(podmanTest.TempDir, "container.conf") infraImage := "k8s.gcr.io/pause:3.2" - err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[engine]\ninfra_image=\"%s\"\n", infraImage)), 0644) + err := os.WriteFile(conffile, []byte(fmt.Sprintf("[engine]\ninfra_image=\"%s\"\n", infraImage)), 0644) Expect(err).To(BeNil()) os.Setenv("CONTAINERS_CONF", conffile) @@ -2370,7 +2369,7 @@ spec: tempdir, err = CreateTempDirInTempDir() Expect(err).To(BeNil()) - err := ioutil.WriteFile(conffile, []byte(testyaml), 0755) + err := os.WriteFile(conffile, []byte(testyaml), 0755) Expect(err).To(BeNil()) kube := podmanTest.Podman([]string{"play", "kube", conffile}) @@ -3800,7 +3799,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q if name == "root" { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -3808,7 +3807,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q Skip("cannot find mappings for the current user") } - initialUsernsConfig, err := ioutil.ReadFile("/proc/self/uid_map") + initialUsernsConfig, err := os.ReadFile("/proc/self/uid_map") Expect(err).To(BeNil()) if os.Geteuid() != 0 { unshare := podmanTest.Podman([]string{"unshare", "cat", "/proc/self/uid_map"}) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 24d9d6854..d694efe5f 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/user" "path/filepath" @@ -332,7 +331,7 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - id, _ := ioutil.ReadFile(targetFile) + id, _ := os.ReadFile(targetFile) check := podmanTest.Podman([]string{"pod", "inspect", "abc"}) check.WaitWithDefaultTimeout() data := check.InspectPodToJSON() @@ -707,7 +706,7 @@ ENTRYPOINT ["sleep","99999"] name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -742,7 +741,7 @@ ENTRYPOINT ["sleep","99999"] name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -778,7 +777,7 @@ ENTRYPOINT ["sleep","99999"] name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -815,7 +814,7 @@ ENTRYPOINT ["sleep","99999"] name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 364ef54d5..d9f319798 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -3,7 +3,6 @@ package integration import ( "fmt" "io/fs" - "io/ioutil" "os" "path/filepath" "strings" @@ -235,7 +234,7 @@ var _ = Describe("Podman pod rm", func() { }) It("podman pod start/remove single pod via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "podID" defer os.RemoveAll(tmpDir) @@ -264,7 +263,7 @@ var _ = Describe("Podman pod rm", func() { }) It("podman pod start/remove multiple pods via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) defer os.RemoveAll(tmpDir) diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index 084a48636..a89613732 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "strconv" "strings" @@ -175,7 +174,7 @@ var _ = Describe("Podman pod start", func() { }) It("podman pod start single pod via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "podID" defer os.RemoveAll(tmpDir) @@ -199,7 +198,7 @@ var _ = Describe("Podman pod start", func() { }) It("podman pod start multiple pods via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) defer os.RemoveAll(tmpDir) @@ -231,7 +230,7 @@ var _ = Describe("Podman pod start", func() { }) It("podman pod create --infra-conmon-pod create + start", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "podID" defer os.RemoveAll(tmpDir) @@ -248,7 +247,7 @@ var _ = Describe("Podman pod start", func() { Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) // infra readFirstLine := func(path string) string { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) Expect(err).To(BeNil()) return strings.Split(string(content), "\n")[0] } diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index 2fe0aa486..b8a9fabc7 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" . "github.com/containers/podman/v4/test/utils" @@ -181,7 +180,7 @@ var _ = Describe("Podman pod stop", func() { }) It("podman pod start/stop single pod via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "podID" defer os.RemoveAll(tmpDir) @@ -210,7 +209,7 @@ var _ = Describe("Podman pod stop", func() { }) It("podman pod start/stop multiple pods via --pod-id-file", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) defer os.RemoveAll(tmpDir) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index a73b7c87b..5af47678f 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -84,7 +83,7 @@ var _ = Describe("Podman push", func() { for _, f := range blobs { blobPath := filepath.Join(blobsDir, f.Name()) - sourceFile, err := ioutil.ReadFile(blobPath) + sourceFile, err := os.ReadFile(blobPath) Expect(err).To(BeNil()) compressionType := archive.DetectCompression(sourceFile) diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 9df884292..87d20a2e6 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "time" @@ -251,7 +250,7 @@ var _ = Describe("Podman restart", func() { }) It("podman restart --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "cid" @@ -274,7 +273,7 @@ var _ = Describe("Podman restart", func() { }) It("podman restart multiple --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile1 := tmpDir + "cid-1" tmpFile2 := tmpDir + "cid-2" diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index e76451824..e931c4419 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" . "github.com/containers/podman/v4/test/utils" @@ -145,7 +144,7 @@ var _ = Describe("Podman rm", func() { }) It("podman rm --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "cid" @@ -166,7 +165,7 @@ var _ = Describe("Podman rm", func() { }) It("podman rm multiple --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile1 := tmpDir + "cid-1" tmpFile2 := tmpDir + "cid-2" diff --git a/test/e2e/run_apparmor_test.go b/test/e2e/run_apparmor_test.go index 18d011e6d..f486054c3 100644 --- a/test/e2e/run_apparmor_test.go +++ b/test/e2e/run_apparmor_test.go @@ -5,7 +5,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -104,7 +103,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) { } ` aaFile := filepath.Join(os.TempDir(), "aaFile") - Expect(ioutil.WriteFile(aaFile, []byte(aaProfile), 0755)).To(BeNil()) + Expect(os.WriteFile(aaFile, []byte(aaProfile), 0755)).To(BeNil()) parse := SystemExec("apparmor_parser", []string{"-Kr", aaFile}) Expect(parse).Should(Exit(0)) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index 24cae43b1..ba3ca922e 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -86,12 +85,12 @@ var _ = Describe("Podman run with --cgroup-parent", func() { containerCgroup := strings.TrimRight(strings.ReplaceAll(exec.OutputToString(), "0::", ""), "\n") // Move the container process to a sub cgroup - content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs")) + content, err := os.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs")) Expect(err).To(BeNil()) oldSubCgroupPath := filepath.Join(cgroupRoot, containerCgroup, "old-container") err = os.MkdirAll(oldSubCgroupPath, 0755) Expect(err).To(BeNil()) - err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644) + err = os.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644) Expect(err).To(BeNil()) newCgroup := fmt.Sprintf("%s/new-container", containerCgroup) diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index 19bb735ff..bdac998cf 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" . "github.com/containers/podman/v4/test/utils" @@ -26,7 +25,7 @@ var _ = Describe("Podman run cpu", func() { } if CGROUPSV2 { - if err := ioutil.WriteFile("/sys/fs/cgroup/cgroup.subtree_control", []byte("+cpuset"), 0644); err != nil { + if err := os.WriteFile("/sys/fs/cgroup/cgroup.subtree_control", []byte("+cpuset"), 0644); err != nil { Skip("cpuset controller not available on the current kernel") } } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 3fbdd4339..fb02cb410 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "net" "os" "os/exec" @@ -638,7 +637,7 @@ USER bin`, BB) Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(Equal("111")) - currentOOMScoreAdj, err := ioutil.ReadFile("/proc/self/oom_score_adj") + currentOOMScoreAdj, err := os.ReadFile("/proc/self/oom_score_adj") Expect(err).To(BeNil()) session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/self/oom_score_adj"}) session.WaitWithDefaultTimeout() @@ -845,7 +844,7 @@ USER bin`, BB) "stage" : [ "prestart" ] } `, hookScriptPath) - err = ioutil.WriteFile(hookJSONPath, []byte(hookJSON), 0644) + err = os.WriteFile(hookJSONPath, []byte(hookJSON), 0644) Expect(err).ToNot(HaveOccurred()) random := stringid.GenerateRandomID() @@ -853,14 +852,14 @@ USER bin`, BB) hookScript := fmt.Sprintf(`#!/bin/sh echo -n %s >%s `, random, targetFile) - err = ioutil.WriteFile(hookScriptPath, []byte(hookScript), 0755) + err = os.WriteFile(hookScriptPath, []byte(hookScript), 0755) Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"--hooks-dir", hooksDir, "run", ALPINE, "ls"}) session.Wait(10) Expect(session).Should(Exit(0)) - b, err := ioutil.ReadFile(targetFile) + b, err := os.ReadFile(targetFile) Expect(err).ToNot(HaveOccurred()) Expect(string(b)).To(Equal(random)) }) @@ -877,19 +876,19 @@ echo -n %s >%s mountsFile := filepath.Join(containersDir, "mounts.conf") mountString := secretsDir + ":/run/secrets" - err = ioutil.WriteFile(mountsFile, []byte(mountString), 0755) + err = os.WriteFile(mountsFile, []byte(mountString), 0755) Expect(err).To(BeNil()) secretsFile := filepath.Join(secretsDir, "test.txt") secretsString := "Testing secrets mount. I am mounted!" - err = ioutil.WriteFile(secretsFile, []byte(secretsString), 0755) + err = os.WriteFile(secretsFile, []byte(secretsString), 0755) Expect(err).To(BeNil()) targetDir := tempdir + "/symlink/target" err = os.MkdirAll(targetDir, 0755) Expect(err).To(BeNil()) keyFile := filepath.Join(targetDir, "key.pem") - err = ioutil.WriteFile(keyFile, []byte(mountString), 0755) + err = os.WriteFile(keyFile, []byte(mountString), 0755) Expect(err).To(BeNil()) execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")}) Expect(execSession).Should(Exit(0)) @@ -908,7 +907,7 @@ echo -n %s >%s It("podman run with FIPS mode secrets", func() { SkipIfRootless("rootless can not manipulate system-fips file") fipsFile := "/etc/system-fips" - err = ioutil.WriteFile(fipsFile, []byte{}, 0755) + err = os.WriteFile(fipsFile, []byte{}, 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls", "/run/secrets"}) @@ -1070,7 +1069,7 @@ USER mail`, BB) filename := "test.txt" volFile := filepath.Join(vol, filename) data := "Testing --volumes-from!!!" - err = ioutil.WriteFile(volFile, []byte(data), 0755) + err = os.WriteFile(volFile, []byte(data), 0755) Expect(err).To(BeNil()) mountpoint := "/myvol/" @@ -1102,7 +1101,7 @@ USER mail`, BB) filename := "test.txt" volFile := filepath.Join(vol, filename) data := "Testing --volumes-from!!!" - err = ioutil.WriteFile(volFile, []byte(data), 0755) + err = os.WriteFile(volFile, []byte(data), 0755) Expect(err).To(BeNil()) mountpoint := "/myvol/" @@ -1469,7 +1468,7 @@ USER mail`, BB) return strings.TrimSuffix(i, "\n") } - curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup") + curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup") Expect(err).ShouldNot(HaveOccurred()) curCgroups := trim(string(curCgroupsBytes)) fmt.Printf("Output:\n%s\n", curCgroups) @@ -1492,7 +1491,7 @@ USER mail`, BB) Skip("Test only works on crun") } - curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup") + curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup") Expect(err).To(BeNil()) var curCgroups string = string(curCgroupsBytes) fmt.Printf("Output:\n%s\n", curCgroups) @@ -1509,7 +1508,7 @@ USER mail`, BB) pid := inspectOut[0].State.Pid Expect(pid).To(Not(Equal(0))) - ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) + ctrCgroupsBytes, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) Expect(err).To(BeNil()) var ctrCgroups string = string(ctrCgroupsBytes) fmt.Printf("Output\n:%s\n", ctrCgroups) @@ -1740,7 +1739,7 @@ WORKDIR /madethis`, BB) It("podman run --secret", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1762,7 +1761,7 @@ WORKDIR /madethis`, BB) It("podman run --secret source=mysecret,type=mount", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1784,7 +1783,7 @@ WORKDIR /madethis`, BB) It("podman run --secret source=mysecret,type=mount with target", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target", secretFilePath}) @@ -1806,7 +1805,7 @@ WORKDIR /madethis`, BB) It("podman run --secret source=mysecret,type=mount with target at /tmp", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target2", secretFilePath}) @@ -1828,7 +1827,7 @@ WORKDIR /madethis`, BB) It("podman run --secret source=mysecret,type=env", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1844,7 +1843,7 @@ WORKDIR /madethis`, BB) It("podman run --secret target option", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1860,7 +1859,7 @@ WORKDIR /madethis`, BB) It("podman run --secret mount with uid, gid, mode options", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1887,7 +1886,7 @@ WORKDIR /madethis`, BB) It("podman run --secret with --user", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1903,7 +1902,7 @@ WORKDIR /madethis`, BB) It("podman run invalid secret option", func() { secretsString := "somesecretdata" secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + err := os.WriteFile(secretFilePath, []byte(secretsString), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) @@ -1968,7 +1967,7 @@ WORKDIR /madethis`, BB) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) readFirstLine := func(path string) string { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) Expect(err).To(BeNil()) return strings.Split(string(content), "\n")[0] } diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 016f67bf6..c485f1522 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/user" "strings" @@ -55,7 +54,7 @@ var _ = Describe("Podman UserNS support", func() { if name == "root" { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -181,7 +180,7 @@ var _ = Describe("Podman UserNS support", func() { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -213,7 +212,7 @@ var _ = Describe("Podman UserNS support", func() { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -251,7 +250,7 @@ var _ = Describe("Podman UserNS support", func() { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -280,7 +279,7 @@ var _ = Describe("Podman UserNS support", func() { name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index aa8f49176..d65be97a4 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "os/exec" "os/user" @@ -768,7 +767,7 @@ VOLUME /test/`, ALPINE) name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } @@ -815,7 +814,7 @@ VOLUME /test/`, ALPINE) name = "containers" } - content, err := ioutil.ReadFile("/etc/subuid") + content, err := os.ReadFile("/etc/subuid") if err != nil { Skip("cannot read /etc/subuid") } diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index afb723a63..f6a06d0ff 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -1,7 +1,6 @@ package integration import ( - "io/ioutil" "os" "os/exec" "path/filepath" @@ -185,7 +184,7 @@ default-docker: sigstore: file:///var/lib/containers/sigstore sigstore-staging: file:///var/lib/containers/sigstore ` - Expect(ioutil.WriteFile("/etc/containers/registries.d/default.yaml", []byte(sigstore), 0755)).To(BeNil()) + Expect(os.WriteFile("/etc/containers/registries.d/default.yaml", []byte(sigstore), 0755)).To(BeNil()) session = podmanTest.Podman([]string{"tag", ALPINE, "localhost:5000/alpine"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index f8b1bc836..77cb72056 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "os" "strconv" "text/template" @@ -288,7 +287,7 @@ registries = ['{{.Host}}:{{.Port}}']` err = registryFileTmpl.Execute(&buffer, ep) Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - err = ioutil.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0644) + err = os.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0644) Expect(err).ToNot(HaveOccurred()) if IsRemote() { podmanTest.RestartRemoteService() @@ -332,7 +331,7 @@ registries = ['{{.Host}}:{{.Port}}']` err = registryFileTmpl.Execute(&buffer, ep) Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - err = ioutil.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0644) + err = os.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0644) Expect(err).ToNot(HaveOccurred()) search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"}) @@ -372,7 +371,7 @@ registries = ['{{.Host}}:{{.Port}}']` err = registryFileBadTmpl.Execute(&buffer, ep) Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - err = ioutil.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0644) + err = os.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0644) Expect(err).ToNot(HaveOccurred()) if IsRemote() { @@ -428,7 +427,7 @@ registries = ['{{.Host}}:{{.Port}}']` err = registryFileTwoTmpl.Execute(&buffer, ep3) Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - err = ioutil.WriteFile(fmt.Sprintf("%s/registry8.conf", tempdir), buffer.Bytes(), 0644) + err = os.WriteFile(fmt.Sprintf("%s/registry8.conf", tempdir), buffer.Bytes(), 0644) Expect(err).ToNot(HaveOccurred()) if IsRemote() { diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index 902f422bd..776dab785 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -37,7 +36,7 @@ var _ = Describe("Podman secret", func() { It("podman secret create", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val", "a", secretFilePath}) @@ -57,7 +56,7 @@ var _ = Describe("Podman secret", func() { It("podman secret create bad name should fail", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "?!", secretFilePath}) @@ -67,7 +66,7 @@ var _ = Describe("Podman secret", func() { It("podman secret inspect", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -83,7 +82,7 @@ var _ = Describe("Podman secret", func() { It("podman secret inspect with --format", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -99,7 +98,7 @@ var _ = Describe("Podman secret", func() { It("podman secret inspect multiple secrets", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -120,7 +119,7 @@ var _ = Describe("Podman secret", func() { It("podman secret inspect bogus", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"}) @@ -131,7 +130,7 @@ var _ = Describe("Podman secret", func() { It("podman secret ls", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -147,7 +146,7 @@ var _ = Describe("Podman secret", func() { It("podman secret ls --quiet", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) secretName := "a" @@ -177,7 +176,7 @@ var _ = Describe("Podman secret", func() { It("podman secret ls with filters", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) secret1 := "Secret1" @@ -231,7 +230,7 @@ var _ = Describe("Podman secret", func() { It("podman secret ls with Go template", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -247,7 +246,7 @@ var _ = Describe("Podman secret", func() { It("podman secret rm", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) @@ -268,7 +267,7 @@ var _ = Describe("Podman secret", func() { It("podman secret rm --all", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") - err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755) + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index f3e8cc015..db6f87ac0 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "strconv" "strings" @@ -204,7 +203,7 @@ var _ = Describe("Podman start", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) readFirstLine := func(path string) string { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) Expect(err).To(BeNil()) return strings.Split(string(content), "\n")[0] } diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 23abb6d92..6f7a67139 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "strings" @@ -276,7 +275,7 @@ var _ = Describe("Podman stop", func() { It("podman stop --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile := tmpDir + "cid" @@ -300,7 +299,7 @@ var _ = Describe("Podman stop", func() { It("podman stop multiple --cidfile", func() { - tmpDir, err := ioutil.TempDir("", "") + tmpDir, err := os.MkdirTemp("", "") Expect(err).To(BeNil()) tmpFile1 := tmpDir + "cid-1" tmpFile2 := tmpDir + "cid-2" diff --git a/test/e2e/system_connection_test.go b/test/e2e/system_connection_test.go index baa31424b..31cbfe349 100644 --- a/test/e2e/system_connection_test.go +++ b/test/e2e/system_connection_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "net/url" "os" "os/exec" @@ -27,7 +26,7 @@ var _ = Describe("podman system connection", func() { BeforeEach(func() { ConfPath.Value, ConfPath.IsSet = os.LookupEnv("CONTAINERS_CONF") - conf, err := ioutil.TempFile("", "containersconf") + conf, err := os.CreateTemp("", "containersconf") Expect(err).ToNot(HaveOccurred()) os.Setenv("CONTAINERS_CONF", conf.Name()) diff --git a/test/e2e/system_service_test.go b/test/e2e/system_service_test.go index 398290426..adb3cade6 100644 --- a/test/e2e/system_service_test.go +++ b/test/e2e/system_service_test.go @@ -1,7 +1,7 @@ package integration import ( - "io/ioutil" + "io" "net" "net/http" "net/url" @@ -89,7 +89,7 @@ var _ = Describe("podman system service", func() { defer resp.Body.Close() Expect(resp).To(HaveHTTPStatus(http.StatusOK)) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ShouldNot(HaveOccurred()) Expect(body).ShouldNot(BeEmpty()) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 7b3552cc2..7b79a724d 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -2,7 +2,6 @@ package integration import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -51,7 +50,7 @@ WantedBy=default.target SkipIfRootless("rootless can not write to /etc") SkipIfContainerized("test does not have systemd as pid 1") - sysFile := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644) + sysFile := os.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644) Expect(sysFile).To(BeNil()) defer func() { stop := SystemExec("bash", []string{"-c", "systemctl stop redis"}) @@ -137,7 +136,7 @@ RUN mkdir -p /usr/lib/systemd/; touch /usr/lib/systemd/systemd CMD /usr/lib/systemd/systemd`, ALPINE) containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile") - err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755) + err := os.WriteFile(containerfilePath, []byte(containerfile), 0755) Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"build", "-t", "systemd", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -167,7 +166,7 @@ CMD /usr/lib/systemd/systemd`, ALPINE) Expect(session).Should(Exit(0)) pidFile := strings.TrimSuffix(session.OutputToString(), "\n") - _, err := ioutil.ReadFile(pidFile) + _, err := os.ReadFile(pidFile) Expect(err).To(BeNil()) }) diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index eee802e43..78b4f1b23 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -2,7 +2,6 @@ package integration import ( "encoding/json" - "io/ioutil" "os" "path/filepath" @@ -57,7 +56,7 @@ var _ = Describe("Podman trust", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) var teststruct map[string][]map[string]string - policyContent, err := ioutil.ReadFile(policyJSON) + policyContent, err := os.ReadFile(policyJSON) if err != nil { os.Exit(1) } @@ -111,7 +110,7 @@ var _ = Describe("Podman trust", func() { session := podmanTest.Podman([]string{"image", "trust", "show", "--policypath", filepath.Join(INTEGRATION_ROOT, "test/policy.json"), "--raw"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - contents, err := ioutil.ReadFile(filepath.Join(INTEGRATION_ROOT, "test/policy.json")) + contents, err := os.ReadFile(filepath.Join(INTEGRATION_ROOT, "test/policy.json")) Expect(err).ShouldNot(HaveOccurred()) Expect(session.OutputToString()).To(BeValidJSON()) Expect(string(session.Out.Contents())).To(Equal(string(contents) + "\n")) |