From 2933c776c53ae7eab8b3bea6d947beda3145f1a6 Mon Sep 17 00:00:00 2001 From: Nick Neisen Date: Mon, 22 Jan 2024 10:30:24 -0700 Subject: [PATCH] Fix the ReadDir methods (#301) --- config/os.go | 7 +++---- .../k8s.io/kubernetes/pkg/kubelet/container/testing/os.go | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config/os.go b/config/os.go index 71cecdbd3..a1234d8ee 100644 --- a/config/os.go +++ b/config/os.go @@ -17,7 +17,6 @@ limitations under the License. package config import ( - "io/ioutil" "os" "path/filepath" "time" @@ -36,7 +35,7 @@ type OSInterface interface { Hostname() (name string, err error) Chtimes(path string, atime time.Time, mtime time.Time) error Pipe() (r *os.File, w *os.File, err error) - ReadDir(dirname string) ([]os.FileInfo, error) + ReadDir(dirname string) ([]os.DirEntry, error) Glob(pattern string) ([]string, error) Open(name string) (*os.File, error) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) @@ -99,8 +98,8 @@ func (RealOS) Pipe() (r *os.File, w *os.File, err error) { } // ReadDir will call ioutil.ReadDir to return the files under the directory. -func (RealOS) ReadDir(dirname string) ([]os.FileInfo, error) { - return ioutil.ReadDir(dirname) +func (RealOS) ReadDir(dirname string) ([]os.DirEntry, error) { + return os.ReadDir(dirname) } // Glob will call filepath.Glob to return the names of all files matching diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/os.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/os.go index b7fe0ccb9..cf84b2576 100644 --- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/os.go +++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/testing/os.go @@ -28,7 +28,7 @@ import ( // of the real call. type FakeOS struct { StatFn func(string) (os.FileInfo, error) - ReadDirFn func(string) ([]os.FileInfo, error) + ReadDirFn func(string) ([]os.DirEntry, error) MkdirAllFn func(string, os.FileMode) error SymlinkFn func(string, string) error GlobFn func(string, string) bool @@ -106,7 +106,7 @@ func (*FakeOS) Pipe() (r *os.File, w *os.File, err error) { } // ReadDir is a fake call that returns the files under the directory. -func (f *FakeOS) ReadDir(dirname string) ([]os.FileInfo, error) { +func (f *FakeOS) ReadDir(dirname string) ([]os.DirEntry, error) { if f.ReadDirFn != nil { return f.ReadDirFn(dirname) }