mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-23 16:27:33 +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:
@@ -21,7 +21,6 @@ package fsquota
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -97,7 +96,7 @@ type mountpointTest struct {
|
||||
}
|
||||
|
||||
func testBackingDev1(testcase backingDevTest) error {
|
||||
tmpfile, err := ioutil.TempFile("", "backingdev")
|
||||
tmpfile, err := os.CreateTemp("", "backingdev")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -502,7 +501,7 @@ var quotaTestCases = []quotaTestCase{
|
||||
}
|
||||
|
||||
func compareProjectsFiles(t *testing.T, testcase quotaTestCase, projectsFile string, projidFile string, enabled bool) {
|
||||
bytes, err := ioutil.ReadFile(projectsFile)
|
||||
bytes, err := os.ReadFile(projectsFile)
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
} else {
|
||||
@@ -515,7 +514,7 @@ func compareProjectsFiles(t *testing.T, testcase quotaTestCase, projectsFile str
|
||||
t.Errorf("Case %v /etc/projects miscompare: expected\n`%s`\ngot\n`%s`\n", testcase.path, p, s)
|
||||
}
|
||||
}
|
||||
bytes, err = ioutil.ReadFile(projidFile)
|
||||
bytes, err = os.ReadFile(projidFile)
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
} else {
|
||||
@@ -598,7 +597,7 @@ func runCaseDisabled(t *testing.T, testcase quotaTestCase, seq int) bool {
|
||||
|
||||
func testAddRemoveQuotas(t *testing.T, enabled bool) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.LocalStorageCapacityIsolationFSQuotaMonitoring, enabled)()
|
||||
tmpProjectsFile, err := ioutil.TempFile("", "projects")
|
||||
tmpProjectsFile, err := os.CreateTemp("", "projects")
|
||||
if err == nil {
|
||||
_, err = tmpProjectsFile.WriteString(projectsHeader)
|
||||
}
|
||||
@@ -607,7 +606,7 @@ func testAddRemoveQuotas(t *testing.T, enabled bool) {
|
||||
}
|
||||
projectsFile = tmpProjectsFile.Name()
|
||||
tmpProjectsFile.Close()
|
||||
tmpProjidFile, err := ioutil.TempFile("", "projid")
|
||||
tmpProjidFile, err := os.CreateTemp("", "projid")
|
||||
if err == nil {
|
||||
_, err = tmpProjidFile.WriteString(projidHeader)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user