summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-12 06:50:48 +0200
committerGitHub <noreply@github.com>2022-09-12 06:50:48 +0200
commit1635fe8620fa454647cf7db2af9ed0c9b52eacfb (patch)
tree814768e6b942e199a6974e2f60a7082a004def18
parent940d3d889221e21cc24705381b2c2d11d75f39bf (diff)
parent118546c6a70704a7b19cb99f3c948b28264628de (diff)
downloadpodman-1635fe8620fa454647cf7db2af9ed0c9b52eacfb.tar.gz
podman-1635fe8620fa454647cf7db2af9ed0c9b52eacfb.tar.bz2
podman-1635fe8620fa454647cf7db2af9ed0c9b52eacfb.zip
Merge pull request #15737 from Juneezee/refactor/os.ReadDir
refactor: use `os.ReadDir` for lightweight directory reading
-rw-r--r--libpod/container_internal.go4
-rw-r--r--libpod/lock/file/file_lock.go3
-rw-r--r--pkg/api/handlers/compat/info.go3
-rw-r--r--pkg/domain/infra/abi/containers.go3
-rw-r--r--pkg/domain/infra/abi/images.go2
-rw-r--r--pkg/util/utils_linux.go5
-rw-r--r--test/e2e/benchmarks_test.go2
-rw-r--r--test/e2e/container_create_volume_test.go2
-rw-r--r--test/e2e/image_sign_test.go3
-rw-r--r--test/e2e/manifest_test.go2
-rw-r--r--test/e2e/push_test.go2
11 files changed, 13 insertions, 18 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 32674235a..227bb7f1f 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1671,7 +1671,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
// a bizarre issue where something copier.Get will ENOENT on
// empty directories and sometimes it will not.
// RHBZ#1928643
- srcContents, err := ioutil.ReadDir(srcDir)
+ srcContents, err := os.ReadDir(srcDir)
if err != nil {
return nil, fmt.Errorf("error reading contents of source directory for copy up into volume %s: %w", vol.Name(), err)
}
@@ -1681,7 +1681,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
// If the volume is not empty, we should not copy up.
volMount := vol.mountPoint()
- contents, err := ioutil.ReadDir(volMount)
+ contents, err := os.ReadDir(volMount)
if err != nil {
return nil, fmt.Errorf("error listing contents of volume %s mountpoint when copying up from container %s: %w", vol.Name(), c.ID(), err)
}
diff --git a/libpod/lock/file/file_lock.go b/libpod/lock/file/file_lock.go
index 1379e690a..55110fc0b 100644
--- a/libpod/lock/file/file_lock.go
+++ b/libpod/lock/file/file_lock.go
@@ -2,7 +2,6 @@ package file
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -129,7 +128,7 @@ func (locks *FileLocks) DeallocateAllLocks() error {
if !locks.valid {
return fmt.Errorf("locks have already been closed: %w", syscall.EINVAL)
}
- files, err := ioutil.ReadDir(locks.lockPath)
+ files, err := os.ReadDir(locks.lockPath)
if err != nil {
return fmt.Errorf("error reading directory %s: %w", locks.lockPath, err)
}
diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go
index d82513284..60bbd40fe 100644
--- a/pkg/api/handlers/compat/info.go
+++ b/pkg/api/handlers/compat/info.go
@@ -2,7 +2,6 @@ package compat
import (
"fmt"
- "io/ioutil"
"net/http"
"os"
goRuntime "runtime"
@@ -198,7 +197,7 @@ func getRuntimes(configInfo *config.Config) map[string]docker.Runtime {
func getFdCount() (count int) {
count = -1
- if entries, err := ioutil.ReadDir("/proc/self/fd"); err == nil {
+ if entries, err := os.ReadDir("/proc/self/fd"); err == nil {
count = len(entries)
}
return
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index dfa3c5ba0..569fe8133 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"strconv"
"sync"
@@ -858,7 +857,7 @@ func makeExecConfig(options entities.ExecOptions, rt *libpod.Runtime) (*libpod.E
func checkExecPreserveFDs(options entities.ExecOptions) error {
if options.PreserveFDs > 0 {
- entries, err := ioutil.ReadDir("/proc/self/fd")
+ entries, err := os.ReadDir("/proc/self/fd")
if err != nil {
return err
}
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index f9839f62f..3030bac20 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -869,7 +869,7 @@ func execTransferPodman(execUser *user.User, command []string, needToTag bool) (
func getSigFilename(sigStoreDirPath string) (string, error) {
sigFileSuffix := 1
- sigFiles, err := ioutil.ReadDir(sigStoreDirPath)
+ sigFiles, err := os.ReadDir(sigStoreDirPath)
if err != nil {
return "", err
}
diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go
index e2d9e3e89..7b2d98666 100644
--- a/pkg/util/utils_linux.go
+++ b/pkg/util/utils_linux.go
@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io/fs"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -119,7 +118,7 @@ func AddPrivilegedDevices(g *generate.Generator) error {
// based on getDevices from runc (libcontainer/devices/devices.go)
func getDevices(path string) ([]spec.LinuxDevice, error) {
- files, err := ioutil.ReadDir(path)
+ files, err := os.ReadDir(path)
if err != nil {
if rootless.IsRootless() && os.IsPermission(err) {
return nil, nil
@@ -146,7 +145,7 @@ func getDevices(path string) ([]spec.LinuxDevice, error) {
}
case f.Name() == "console":
continue
- case f.Mode()&os.ModeSymlink != 0:
+ case f.Type()&os.ModeSymlink != 0:
continue
}
diff --git a/test/e2e/benchmarks_test.go b/test/e2e/benchmarks_test.go
index 4be048de2..d1332665a 100644
--- a/test/e2e/benchmarks_test.go
+++ b/test/e2e/benchmarks_test.go
@@ -99,7 +99,7 @@ var _ = Describe("Podman Benchmark Suite", func() {
}
totalMemoryInKb := func() (total uint64) {
- files, err := ioutil.ReadDir(timedir)
+ files, err := os.ReadDir(timedir)
if err != nil {
Fail(fmt.Sprintf("Error reading timing dir: %v", err))
}
diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go
index 6d9f13694..3c54691aa 100644
--- a/test/e2e/container_create_volume_test.go
+++ b/test/e2e/container_create_volume_test.go
@@ -58,7 +58,7 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d
Expect(volList.OutputToStringArray()[0]).To(Equal(mntName))
// Check the mount source directory
- files, err := ioutil.ReadDir(mntSource)
+ files, err := os.ReadDir(mntSource)
Expect(err).To(BeNil())
if data == "" {
diff --git a/test/e2e/image_sign_test.go b/test/e2e/image_sign_test.go
index 3c819a7d2..5568acc01 100644
--- a/test/e2e/image_sign_test.go
+++ b/test/e2e/image_sign_test.go
@@ -1,7 +1,6 @@
package integration
import (
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -69,7 +68,7 @@ var _ = Describe("Podman image sign", func() {
session := podmanTest.Podman([]string{"image", "sign", "--all", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- fInfos, err := ioutil.ReadDir(filepath.Join(sigDir, "library"))
+ fInfos, err := os.ReadDir(filepath.Join(sigDir, "library"))
Expect(err).To(BeNil())
Expect(len(fInfos)).To(BeNumerically(">", 1), "len(fInfos)")
})
diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go
index 60b72dcaa..e38499257 100644
--- a/test/e2e/manifest_test.go
+++ b/test/e2e/manifest_test.go
@@ -332,7 +332,7 @@ var _ = Describe("Podman manifest", func() {
blobsDir := filepath.Join(dest, "blobs", "sha256")
- blobs, err := ioutil.ReadDir(blobsDir)
+ blobs, err := os.ReadDir(blobsDir)
Expect(err).To(BeNil())
for _, f := range blobs {
diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go
index 898d21d00..a73b7c87b 100644
--- a/test/e2e/push_test.go
+++ b/test/e2e/push_test.go
@@ -78,7 +78,7 @@ var _ = Describe("Podman push", func() {
blobsDir := filepath.Join(bbdir, "blobs/sha256")
- blobs, err := ioutil.ReadDir(blobsDir)
+ blobs, err := os.ReadDir(blobsDir)
Expect(err).To(BeNil())
for _, f := range blobs {