mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-26 03:15:11 +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:
@@ -20,7 +20,6 @@ limitations under the License.
|
||||
package hostutil
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -193,12 +192,12 @@ func TestGetSELinuxSupport(t *testing.T) {
|
||||
}
|
||||
|
||||
func writeFile(content string) (string, string, error) {
|
||||
tempDir, err := ioutil.TempDir("", "mounter_shared_test")
|
||||
tempDir, err := os.MkdirTemp("", "mounter_shared_test")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
filename := filepath.Join(tempDir, "mountinfo")
|
||||
err = ioutil.WriteFile(filename, []byte(content), 0600)
|
||||
err = os.WriteFile(filename, []byte(content), 0600)
|
||||
if err != nil {
|
||||
os.RemoveAll(tempDir)
|
||||
return "", "", err
|
||||
|
||||
Reference in New Issue
Block a user