From c47fa95d93510dc7043e2933cf496a8fe7aa74cc Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Fri, 2 Jun 2023 09:53:46 +0800 Subject: [PATCH 1/2] io/ioutil deprecated --- pkg/volume/csi/csi_attacher_test.go | 3 +-- pkg/volume/csi/csi_mounter_test.go | 3 +-- pkg/volume/csi/csi_util_test.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/volume/csi/csi_attacher_test.go b/pkg/volume/csi/csi_attacher_test.go index 1494316eac0..d2ed6ba37e4 100644 --- a/pkg/volume/csi/csi_attacher_test.go +++ b/pkg/volume/csi/csi_attacher_test.go @@ -20,7 +20,6 @@ import ( "context" "crypto/sha256" "fmt" - "io/ioutil" "os" "os/user" "path/filepath" @@ -1644,7 +1643,7 @@ func TestAttacherUnmountDevice(t *testing.T) { // Make JSON for this object if tc.jsonFile != "" { dataPath := filepath.Join(dir, volDataFileName) - if err := ioutil.WriteFile(dataPath, []byte(tc.jsonFile), 0644); err != nil { + if err := os.WriteFile(dataPath, []byte(tc.jsonFile), 0644); err != nil { t.Fatalf("error creating %s: %s", dataPath, err) } } diff --git a/pkg/volume/csi/csi_mounter_test.go b/pkg/volume/csi/csi_mounter_test.go index c1c487f2d95..a5e542ea6a4 100644 --- a/pkg/volume/csi/csi_mounter_test.go +++ b/pkg/volume/csi/csi_mounter_test.go @@ -19,7 +19,6 @@ package csi import ( "context" "fmt" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -1065,7 +1064,7 @@ func TestUnmounterTeardown(t *testing.T) { } func TestIsCorruptedDir(t *testing.T) { - existingMountPath, err := ioutil.TempDir(os.TempDir(), "blobfuse-csi-mount-test") + existingMountPath, err := os.MkdirTemp(os.TempDir(), "blobfuse-csi-mount-test") if err != nil { t.Fatalf("failed to create tmp dir: %v", err) } diff --git a/pkg/volume/csi/csi_util_test.go b/pkg/volume/csi/csi_util_test.go index 4450c268161..1a20f6e1754 100644 --- a/pkg/volume/csi/csi_util_test.go +++ b/pkg/volume/csi/csi_util_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -143,7 +142,7 @@ func TestSaveVolumeData(t *testing.T) { } // validate content - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if !tc.shouldFail && err != nil { t.Errorf("failed to read data file: %v", err) } From 58751405a6f4ca318e7ee3eec15e22704ec915b9 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Fri, 2 Jun 2023 11:11:07 +0800 Subject: [PATCH 2/2] chore: io/ioutil deprecated --- pkg/volume/csi/fake/fake_client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/volume/csi/fake/fake_client.go b/pkg/volume/csi/fake/fake_client.go index 6883edefda6..037beaa4909 100644 --- a/pkg/volume/csi/fake/fake_client.go +++ b/pkg/volume/csi/fake/fake_client.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "strings" @@ -205,7 +204,7 @@ func (f *NodeClient) NodePublishVolume(ctx context.Context, req *csipb.NodePubli // "Creation of target_path is the responsibility of the SP." // Our plugin depends on it. if req.VolumeCapability.GetBlock() != nil { - if err := ioutil.WriteFile(req.TargetPath, []byte{}, 0644); err != nil { + if err := os.WriteFile(req.TargetPath, []byte{}, 0644); err != nil { return nil, fmt.Errorf("cannot create target path %s for block file: %s", req.TargetPath, err) } } else {