mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-26 19:35:10 +00:00
storage: stop using deprecated io/ioutil
This replaces deprecated ioutil variables and functions as follows: * ioutil.ReadDir -> os.ReadDir * ioutil.ReadFile -> os.ReadFile * ioutil.TempDir -> os.MkdirTemp * ioutil.TempFile -> os.CreateTemp * ioutil.WriteFile -> os.WriteFile The ReadDir conversion involves an API change, the replacement function returns a slice of fs.DirEntry instead of fs.FileInfo. Where appropriate, the surrounding code has been adjusted; mostly, that means using DirEntry.Type() instead of FileInfo.Mode(). Applying this change to the IoUtil interface would mean changing its API, so this is left for later. Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
@@ -18,7 +18,6 @@ package projected
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -874,7 +873,7 @@ func TestCollectDataWithServiceAccountToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func newTestHost(t *testing.T, clientset clientset.Interface) (string, volume.VolumeHost) {
|
||||
tempDir, err := ioutil.TempDir("", "projected_volume_test.")
|
||||
tempDir, err := os.MkdirTemp("", "projected_volume_test.")
|
||||
if err != nil {
|
||||
t.Fatalf("can't make a temp rootdir: %v", err)
|
||||
}
|
||||
@@ -1139,7 +1138,7 @@ func TestPluginOptional(t *testing.T) {
|
||||
}
|
||||
datadirPath := filepath.Join(volumePath, datadir)
|
||||
|
||||
infos, err := ioutil.ReadDir(volumePath)
|
||||
infos, err := os.ReadDir(volumePath)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't find volume path, %s", volumePath)
|
||||
}
|
||||
@@ -1151,7 +1150,7 @@ func TestPluginOptional(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
infos, err = ioutil.ReadDir(datadirPath)
|
||||
infos, err = os.ReadDir(datadirPath)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't find volume data path, %s", datadirPath)
|
||||
}
|
||||
@@ -1292,7 +1291,7 @@ func doTestSecretDataInVolume(volumePath string, secret v1.Secret, t *testing.T)
|
||||
if _, err := os.Stat(secretDataHostPath); err != nil {
|
||||
t.Fatalf("SetUp() failed, couldn't find secret data on disk: %v", secretDataHostPath)
|
||||
} else {
|
||||
actualSecretBytes, err := ioutil.ReadFile(secretDataHostPath)
|
||||
actualSecretBytes, err := os.ReadFile(secretDataHostPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't read secret data from: %v", secretDataHostPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user