aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-21 16:12:25 +0200
committerGitHub <noreply@github.com>2022-09-21 16:12:25 +0200
commit12655484e39eadbc0fa0607542aa4a49a21013a1 (patch)
tree9690fd321a567f302c0fc2d46854b00316af3957 /libpod
parenta4399ef813840b48fc027edc3d0bdedf8a038f23 (diff)
parentd968f3fe09a4c7d74464cfe2eaa9e4febbe61ba5 (diff)
downloadpodman-12655484e39eadbc0fa0607542aa4a49a21013a1.tar.gz
podman-12655484e39eadbc0fa0607542aa4a49a21013a1.tar.bz2
podman-12655484e39eadbc0fa0607542aa4a49a21013a1.zip
Merge pull request #15871 from cevich/replace_ioutil
Replace deprecated ioutil
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go6
-rw-r--r--libpod/container_api.go5
-rw-r--r--libpod/container_exec.go3
-rw-r--r--libpod/container_internal.go7
-rw-r--r--libpod/container_internal_common.go7
-rw-r--r--libpod/container_internal_test.go4
-rw-r--r--libpod/events/logfile.go5
-rw-r--r--libpod/events/logfile_test.go17
-rw-r--r--libpod/healthcheck.go7
-rw-r--r--libpod/networking_linux.go5
-rw-r--r--libpod/networking_machine.go3
-rw-r--r--libpod/networking_slirp4netns.go11
-rw-r--r--libpod/oci_conmon_common.go13
-rw-r--r--libpod/oci_conmon_exec_common.go5
-rw-r--r--libpod/plugin/volume_api.go14
-rw-r--r--libpod/runtime_img.go3
-rw-r--r--libpod/runtime_migrate.go3
-rw-r--r--libpod/state_test.go3
18 files changed, 53 insertions, 68 deletions
diff --git a/libpod/container.go b/libpod/container.go
index cfffd8ea1..a4eb33c49 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -3,7 +3,7 @@ package libpod
import (
"bytes"
"fmt"
- "io/ioutil"
+ "io"
"net"
"os"
"strings"
@@ -351,7 +351,7 @@ func (c *Container) specFromState() (*spec.Spec, error) {
if f, err := os.Open(c.state.ConfigPath); err == nil {
returnSpec = new(spec.Spec)
- content, err := ioutil.ReadAll(f)
+ content, err := io.ReadAll(f)
if err != nil {
return nil, fmt.Errorf("reading container config: %w", err)
}
@@ -990,7 +990,7 @@ func (c *Container) cGroupPath() (string, error) {
// the lookup.
// See #10602 for more details.
procPath := fmt.Sprintf("/proc/%d/cgroup", c.state.PID)
- lines, err := ioutil.ReadFile(procPath)
+ lines, err := os.ReadFile(procPath)
if err != nil {
// If the file doesn't exist, it means the container could have been terminated
// so report it.
diff --git a/libpod/container_api.go b/libpod/container_api.go
index dd47b4d12..be0ca0128 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net/http"
"os"
"sync"
@@ -479,7 +478,7 @@ func (c *Container) AddArtifact(name string, data []byte) error {
return define.ErrCtrRemoved
}
- return ioutil.WriteFile(c.getArtifactPath(name), data, 0o740)
+ return os.WriteFile(c.getArtifactPath(name), data, 0o740)
}
// GetArtifact reads the specified artifact file from the container
@@ -488,7 +487,7 @@ func (c *Container) GetArtifact(name string) ([]byte, error) {
return nil, define.ErrCtrRemoved
}
- return ioutil.ReadFile(c.getArtifactPath(name))
+ return os.ReadFile(c.getArtifactPath(name))
}
// RemoveArtifact deletes the specified artifacts file
diff --git a/libpod/container_exec.go b/libpod/container_exec.go
index 3a2cba52f..7896d1932 100644
--- a/libpod/container_exec.go
+++ b/libpod/container_exec.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"net/http"
"os"
"path/filepath"
@@ -928,7 +927,7 @@ func (c *Container) readExecExitCode(sessionID string) (int, error) {
if err != nil {
return -1, err
}
- ec, err := ioutil.ReadFile(exitFile)
+ ec, err := os.ReadFile(exitFile)
if err != nil {
return -1, err
}
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 994243805..9bf93412d 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -201,7 +200,7 @@ func (c *Container) waitForExitFileAndSync() error {
// This assumes the exit file already exists.
func (c *Container) handleExitFile(exitFile string, fi os.FileInfo) error {
c.state.FinishedTime = ctime.Created(fi)
- statusCodeStr, err := ioutil.ReadFile(exitFile)
+ statusCodeStr, err := os.ReadFile(exitFile)
if err != nil {
return fmt.Errorf("failed to read exit file for container %s: %w", c.ID(), err)
}
@@ -2089,7 +2088,7 @@ func (c *Container) saveSpec(spec *spec.Spec) error {
if err != nil {
return fmt.Errorf("exporting runtime spec for container %s to JSON: %w", c.ID(), err)
}
- if err := ioutil.WriteFile(jsonPath, fileJSON, 0644); err != nil {
+ if err := os.WriteFile(jsonPath, fileJSON, 0644); err != nil {
return fmt.Errorf("writing runtime spec JSON for container %s to disk: %w", c.ID(), err)
}
@@ -2343,7 +2342,7 @@ func (c *Container) extractSecretToCtrStorage(secr *ContainerSecret) error {
if err != nil {
return fmt.Errorf("unable to extract secret: %w", err)
}
- err = ioutil.WriteFile(secretFile, data, 0644)
+ err = os.WriteFile(secretFile, data, 0644)
if err != nil {
return fmt.Errorf("unable to create %s: %w", secretFile, err)
}
diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go
index a0ae22ff4..874e9affe 100644
--- a/libpod/container_internal_common.go
+++ b/libpod/container_internal_common.go
@@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"math"
"os"
"os/user"
@@ -788,7 +787,7 @@ func (c *Container) createCheckpointImage(ctx context.Context, options Container
}
// Export checkpoint into temporary tar file
- tmpDir, err := ioutil.TempDir("", "checkpoint_image_")
+ tmpDir, err := os.MkdirTemp("", "checkpoint_image_")
if err != nil {
return err
}
@@ -2442,7 +2441,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) {
if err != nil {
return "", "", fmt.Errorf("creating path to container %s /etc/passwd: %w", c.ID(), err)
}
- orig, err := ioutil.ReadFile(originPasswdFile)
+ orig, err := os.ReadFile(originPasswdFile)
if err != nil && !os.IsNotExist(err) {
return "", "", err
}
@@ -2488,7 +2487,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) {
if err != nil {
return "", "", fmt.Errorf("creating path to container %s /etc/group: %w", c.ID(), err)
}
- orig, err := ioutil.ReadFile(originGroupFile)
+ orig, err := os.ReadFile(originGroupFile)
if err != nil && !os.IsNotExist(err) {
return "", "", err
}
diff --git a/libpod/container_internal_test.go b/libpod/container_internal_test.go
index 1b4e62e91..46a2da544 100644
--- a/libpod/container_internal_test.go
+++ b/libpod/container_internal_test.go
@@ -3,7 +3,7 @@ package libpod
import (
"context"
"fmt"
- "io/ioutil"
+ "os"
"path/filepath"
"runtime"
"testing"
@@ -60,7 +60,7 @@ func TestPostDeleteHooks(t *testing.T) {
for _, p := range []string{statePath, copyPath} {
path := p
t.Run(path, func(t *testing.T) {
- content, err := ioutil.ReadFile(path)
+ content, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go
index d749a0d4d..bb0f461e3 100644
--- a/libpod/events/logfile.go
+++ b/libpod/events/logfile.go
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"path"
"path/filepath"
@@ -204,11 +203,11 @@ func truncate(filePath string) error {
size := origFinfo.Size()
threshold := size / 2
- tmp, err := ioutil.TempFile(path.Dir(filePath), "")
+ tmp, err := os.CreateTemp(path.Dir(filePath), "")
if err != nil {
// Retry in /tmp in case creating a tmp file in the same
// directory has failed.
- tmp, err = ioutil.TempFile("", "")
+ tmp, err = os.CreateTemp("", "")
if err != nil {
return err
}
diff --git a/libpod/events/logfile_test.go b/libpod/events/logfile_test.go
index 302533c12..50141168e 100644
--- a/libpod/events/logfile_test.go
+++ b/libpod/events/logfile_test.go
@@ -1,7 +1,6 @@
package events
import (
- "io/ioutil"
"os"
"testing"
@@ -29,7 +28,7 @@ func TestRotateLog(t *testing.T) {
}
for _, test := range tests {
- tmp, err := ioutil.TempFile("", "log-rotation-")
+ tmp, err := os.CreateTemp("", "log-rotation-")
require.NoError(t, err)
defer os.Remove(tmp.Name())
defer tmp.Close()
@@ -84,7 +83,7 @@ func TestTruncationOutput(t *testing.T) {
10
`
// Create dummy file
- tmp, err := ioutil.TempFile("", "log-rotation")
+ tmp, err := os.CreateTemp("", "log-rotation")
require.NoError(t, err)
defer os.Remove(tmp.Name())
defer tmp.Close()
@@ -94,11 +93,11 @@ func TestTruncationOutput(t *testing.T) {
require.NoError(t, err)
// Truncate the file
- beforeTruncation, err := ioutil.ReadFile(tmp.Name())
+ beforeTruncation, err := os.ReadFile(tmp.Name())
require.NoError(t, err)
err = truncate(tmp.Name())
require.NoError(t, err)
- afterTruncation, err := ioutil.ReadFile(tmp.Name())
+ afterTruncation, err := os.ReadFile(tmp.Name())
require.NoError(t, err)
// Test if rotation was successful
@@ -116,9 +115,9 @@ func TestRenameLog(t *testing.T) {
5
`
// Create two dummy files
- source, err := ioutil.TempFile("", "removing")
+ source, err := os.CreateTemp("", "removing")
require.NoError(t, err)
- target, err := ioutil.TempFile("", "renaming")
+ target, err := os.CreateTemp("", "renaming")
require.NoError(t, err)
// Write to source dummy file
@@ -126,11 +125,11 @@ func TestRenameLog(t *testing.T) {
require.NoError(t, err)
// Rename the files
- beforeRename, err := ioutil.ReadFile(source.Name())
+ beforeRename, err := os.ReadFile(source.Name())
require.NoError(t, err)
err = renameLog(source.Name(), target.Name())
require.NoError(t, err)
- afterRename, err := ioutil.ReadFile(target.Name())
+ afterRename, err := os.ReadFile(target.Name())
require.NoError(t, err)
// Test if renaming was successful
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index e835af9f0..a589f2787 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -208,7 +207,7 @@ func (c *Container) updateHealthStatus(status string) error {
if err != nil {
return fmt.Errorf("unable to marshall healthchecks for writing status: %w", err)
}
- return ioutil.WriteFile(c.healthCheckLogPath(), newResults, 0700)
+ return os.WriteFile(c.healthCheckLogPath(), newResults, 0700)
}
// UpdateHealthCheckLog parses the health check results and writes the log
@@ -242,7 +241,7 @@ func (c *Container) updateHealthCheckLog(hcl define.HealthCheckLog, inStartPerio
if err != nil {
return fmt.Errorf("unable to marshall healthchecks for writing: %w", err)
}
- return ioutil.WriteFile(c.healthCheckLogPath(), newResults, 0700)
+ return os.WriteFile(c.healthCheckLogPath(), newResults, 0700)
}
// HealthCheckLogPath returns the path for where the health check log is
@@ -259,7 +258,7 @@ func (c *Container) getHealthCheckLog() (define.HealthCheckResults, error) {
if _, err := os.Stat(c.healthCheckLogPath()); os.IsNotExist(err) {
return healthCheck, nil
}
- b, err := ioutil.ReadFile(c.healthCheckLogPath())
+ b, err := os.ReadFile(c.healthCheckLogPath())
if err != nil {
return healthCheck, fmt.Errorf("failed to read health check log file: %w", err)
}
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index e27ec8e9d..6ea56ade5 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -8,7 +8,6 @@ import (
"crypto/sha256"
"errors"
"fmt"
- "io/ioutil"
"net"
"os"
"os/exec"
@@ -303,7 +302,7 @@ func (r *RootlessNetNS) Cleanup(runtime *Runtime) error {
if err != nil {
logrus.Error(err)
}
- b, err := ioutil.ReadFile(r.getPath(rootlessNetNsSilrp4netnsPidFile))
+ b, err := os.ReadFile(r.getPath(rootlessNetNsSilrp4netnsPidFile))
if err == nil {
var i int
i, err = strconv.Atoi(string(b))
@@ -445,7 +444,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
// create pid file for the slirp4netns process
// this is need to kill the process in the cleanup
pid := strconv.Itoa(cmd.Process.Pid)
- err = ioutil.WriteFile(filepath.Join(rootlessNetNsDir, rootlessNetNsSilrp4netnsPidFile), []byte(pid), 0700)
+ err = os.WriteFile(filepath.Join(rootlessNetNsDir, rootlessNetNsSilrp4netnsPidFile), []byte(pid), 0700)
if err != nil {
return nil, fmt.Errorf("unable to write rootless-netns slirp4netns pid file: %w", err)
}
diff --git a/libpod/networking_machine.go b/libpod/networking_machine.go
index 7b8eb94df..dce335c0a 100644
--- a/libpod/networking_machine.go
+++ b/libpod/networking_machine.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"strconv"
@@ -109,7 +108,7 @@ func makeMachineRequest(ctx context.Context, client *http.Client, url string, bu
}
func annotateGvproxyResponseError(r io.Reader) error {
- b, err := ioutil.ReadAll(r)
+ b, err := io.ReadAll(r)
if err == nil && len(b) > 0 {
return fmt.Errorf("something went wrong with the request: %q", string(b))
}
diff --git a/libpod/networking_slirp4netns.go b/libpod/networking_slirp4netns.go
index d4ec9082b..4026b6b48 100644
--- a/libpod/networking_slirp4netns.go
+++ b/libpod/networking_slirp4netns.go
@@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net"
"os"
"os/exec"
@@ -324,7 +323,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns ns.NetNS) error {
// correct value assigned so DAD is disabled for it
// Also make sure to change this value back to the original after slirp4netns
// is ready in case users rely on this sysctl.
- orgValue, err := ioutil.ReadFile(ipv6ConfDefaultAcceptDadSysctl)
+ orgValue, err := os.ReadFile(ipv6ConfDefaultAcceptDadSysctl)
if err != nil {
netnsReadyWg.Done()
// on ipv6 disabled systems the sysctl does not exists
@@ -334,7 +333,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns ns.NetNS) error {
}
return err
}
- err = ioutil.WriteFile(ipv6ConfDefaultAcceptDadSysctl, []byte("0"), 0644)
+ err = os.WriteFile(ipv6ConfDefaultAcceptDadSysctl, []byte("0"), 0644)
netnsReadyWg.Done()
if err != nil {
return err
@@ -342,7 +341,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns ns.NetNS) error {
// wait until slirp4nets is ready before resetting this value
slirpReadyWg.Wait()
- return ioutil.WriteFile(ipv6ConfDefaultAcceptDadSysctl, orgValue, 0644)
+ return os.WriteFile(ipv6ConfDefaultAcceptDadSysctl, orgValue, 0644)
})
if err != nil {
logrus.Warnf("failed to set net.ipv6.conf.default.accept_dad sysctl: %v", err)
@@ -486,7 +485,7 @@ func waitForSync(syncR *os.File, cmd *exec.Cmd, logFile io.ReadSeeker, timeout t
if _, err := logFile.Seek(0, 0); err != nil {
logrus.Errorf("Could not seek log file: %q", err)
}
- logContent, err := ioutil.ReadAll(logFile)
+ logContent, err := io.ReadAll(logFile)
if err != nil {
return fmt.Errorf("%s failed: %w", prog, err)
}
@@ -730,7 +729,7 @@ func (c *Container) reloadRootlessRLKPortMapping() error {
if err != nil {
return fmt.Errorf("port reloading failed: %w", err)
}
- b, err := ioutil.ReadAll(conn)
+ b, err := io.ReadAll(conn)
if err != nil {
return fmt.Errorf("port reloading failed: %w", err)
}
diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go
index 53dddd064..cbdbad02d 100644
--- a/libpod/oci_conmon_common.go
+++ b/libpod/oci_conmon_common.go
@@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"os"
@@ -232,7 +231,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
}
if err := cmd.Start(); err != nil {
- out, err2 := ioutil.ReadAll(errPipe)
+ out, err2 := io.ReadAll(errPipe)
if err2 != nil {
return fmt.Errorf("getting container %s state: %w", ctr.ID(), err)
}
@@ -254,7 +253,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
if err := errPipe.Close(); err != nil {
return err
}
- out, err := ioutil.ReadAll(outPipe)
+ out, err := io.ReadAll(outPipe)
if err != nil {
return fmt.Errorf("reading stdout: %s: %w", ctr.ID(), err)
}
@@ -335,7 +334,7 @@ func generateResourceFile(res *spec.LinuxResources) (string, []string, error) {
return "", flags, nil
}
- f, err := ioutil.TempFile("", "podman")
+ f, err := os.CreateTemp("", "podman")
if err != nil {
return "", nil, err
}
@@ -1398,7 +1397,7 @@ func newPipe() (*os.File, *os.File, error) {
func readConmonPidFile(pidFile string) (int, error) {
// Let's try reading the Conmon pid at the same time.
if pidFile != "" {
- contents, err := ioutil.ReadFile(pidFile)
+ contents, err := os.ReadFile(pidFile)
if err != nil {
return -1, err
}
@@ -1447,7 +1446,7 @@ func readConmonPipeData(runtimeName string, pipe *os.File, ociLog string) (int,
case ss := <-ch:
if ss.err != nil {
if ociLog != "" {
- ociLogData, err := ioutil.ReadFile(ociLog)
+ ociLogData, err := os.ReadFile(ociLog)
if err == nil {
var ociErr ociError
if err := json.Unmarshal(ociLogData, &ociErr); err == nil {
@@ -1460,7 +1459,7 @@ func readConmonPipeData(runtimeName string, pipe *os.File, ociLog string) (int,
logrus.Debugf("Received: %d", ss.si.Data)
if ss.si.Data < 0 {
if ociLog != "" {
- ociLogData, err := ioutil.ReadFile(ociLog)
+ ociLogData, err := os.ReadFile(ociLog)
if err == nil {
var ociErr ociError
if err := json.Unmarshal(ociLogData, &ociErr); err == nil {
diff --git a/libpod/oci_conmon_exec_common.go b/libpod/oci_conmon_exec_common.go
index e5080942b..24113bd8d 100644
--- a/libpod/oci_conmon_exec_common.go
+++ b/libpod/oci_conmon_exec_common.go
@@ -3,7 +3,6 @@ package libpod
import (
"errors"
"fmt"
- "io/ioutil"
"net/http"
"os"
"os/exec"
@@ -665,7 +664,7 @@ func attachExecHTTP(c *Container, sessionID string, r *http.Request, w http.Resp
// prepareProcessExec returns the path of the process.json used in runc exec -p
// caller is responsible to close the returned *os.File if needed.
func (c *Container) prepareProcessExec(options *ExecOptions, env []string, sessionID string) (*os.File, error) {
- f, err := ioutil.TempFile(c.execBundlePath(sessionID), "exec-process-")
+ f, err := os.CreateTemp(c.execBundlePath(sessionID), "exec-process-")
if err != nil {
return nil, err
}
@@ -764,7 +763,7 @@ func (c *Container) prepareProcessExec(options *ExecOptions, env []string, sessi
return nil, err
}
- if err := ioutil.WriteFile(f.Name(), processJSON, 0644); err != nil {
+ if err := os.WriteFile(f.Name(), processJSON, 0644); err != nil {
return nil, err
}
return f, nil
diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go
index 522895798..c595937ae 100644
--- a/libpod/plugin/volume_api.go
+++ b/libpod/plugin/volume_api.go
@@ -5,7 +5,7 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"net"
"net/http"
"os"
@@ -95,7 +95,7 @@ func validatePlugin(newPlugin *VolumePlugin) error {
}
// Read and decode the body so we can tell if this is a volume plugin.
- respBytes, err := ioutil.ReadAll(resp.Body)
+ respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("reading activation response body from plugin %s: %w", newPlugin.Name, err)
}
@@ -252,7 +252,7 @@ func (p *VolumePlugin) handleErrorResponse(resp *http.Response, endpoint, volNam
// Let's interpret anything other than 200 as an error.
// If there isn't an error, don't even bother decoding the response.
if resp.StatusCode != 200 {
- errResp, err := ioutil.ReadAll(resp.Body)
+ errResp, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err)
}
@@ -307,7 +307,7 @@ func (p *VolumePlugin) ListVolumes() ([]*volume.Volume, error) {
return nil, err
}
- volumeRespBytes, err := ioutil.ReadAll(resp.Body)
+ volumeRespBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err)
}
@@ -342,7 +342,7 @@ func (p *VolumePlugin) GetVolume(req *volume.GetRequest) (*volume.Volume, error)
return nil, err
}
- getRespBytes, err := ioutil.ReadAll(resp.Body)
+ getRespBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err)
}
@@ -398,7 +398,7 @@ func (p *VolumePlugin) GetVolumePath(req *volume.PathRequest) (string, error) {
return "", err
}
- pathRespBytes, err := ioutil.ReadAll(resp.Body)
+ pathRespBytes, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err)
}
@@ -435,7 +435,7 @@ func (p *VolumePlugin) MountVolume(req *volume.MountRequest) (string, error) {
return "", err
}
- mountRespBytes, err := ioutil.ReadAll(resp.Body)
+ mountRespBytes, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err)
}
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index dacbd752f..87b77c3eb 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
buildahDefine "github.com/containers/buildah/define"
@@ -105,7 +104,7 @@ func (r *Runtime) Build(ctx context.Context, options buildahDefine.BuildOptions,
// DownloadFromFile reads all of the content from the reader and temporarily
// saves in it $TMPDIR/importxyz, which is deleted after the image is imported
func DownloadFromFile(reader *os.File) (string, error) {
- outFile, err := ioutil.TempFile(util.Tmpdir(), "import")
+ outFile, err := os.CreateTemp(util.Tmpdir(), "import")
if err != nil {
return "", fmt.Errorf("creating file: %w", err)
}
diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go
index 36901d4d0..df1a1f1cb 100644
--- a/libpod/runtime_migrate.go
+++ b/libpod/runtime_migrate.go
@@ -5,7 +5,6 @@ package libpod
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -23,7 +22,7 @@ func (r *Runtime) stopPauseProcess() error {
if err != nil {
return fmt.Errorf("could not get pause process pid file path: %w", err)
}
- data, err := ioutil.ReadFile(pausePidPath)
+ data, err := os.ReadFile(pausePidPath)
if err != nil {
if os.IsNotExist(err) {
return nil
diff --git a/libpod/state_test.go b/libpod/state_test.go
index 3c1fe8f63..7664f7c00 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -1,7 +1,6 @@
package libpod
import (
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -35,7 +34,7 @@ var (
// Get an empty BoltDB state for use in tests
func getEmptyBoltState() (_ State, _ string, _ lock.Manager, retErr error) {
- tmpDir, err := ioutil.TempDir("", tmpDirPrefix)
+ tmpDir, err := os.MkdirTemp("", tmpDirPrefix)
if err != nil {
return nil, "", nil, err
}