Remove ioutil in kubelet and its tests

Signed-off-by: inosato <si17_21@yahoo.co.jp>
This commit is contained in:
inosato
2022-07-18 23:51:51 +09:00
parent f6e163fe27
commit 3b95d3b076
40 changed files with 222 additions and 253 deletions

View File

@@ -19,7 +19,6 @@ package kubelet
import (
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
@@ -182,11 +181,11 @@ fe00::2 ip6-allrouters
// writeHostsFile will write a hosts file into a temporary dir, and return that dir.
// Caller is responsible for deleting the dir and its contents.
func writeHostsFile(filename string, cfg string) (string, error) {
tmpdir, err := ioutil.TempDir("", "kubelet=kubelet_pods_test.go=")
tmpdir, err := os.MkdirTemp("", "kubelet=kubelet_pods_test.go=")
if err != nil {
return "", err
}
return tmpdir, ioutil.WriteFile(filepath.Join(tmpdir, filename), []byte(cfg), 0644)
return tmpdir, os.WriteFile(filepath.Join(tmpdir, filename), []byte(cfg), 0644)
}
func TestManagedHostsFileContent(t *testing.T) {