Skip to content

Commit

Permalink
Merge pull request #598 from umagnus/replace-deprecated-ioutil
Browse files Browse the repository at this point in the history
cleanup: replace deprecated ioutil method
  • Loading branch information
k8s-ci-robot authored Apr 20, 2023
2 parents 86dacf7 + d7fb687 commit 862a138
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions pkg/smb/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package smb

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -382,7 +381,7 @@ func (d *Driver) ensureMountPoint(target string) (bool, error) {

if !notMnt {
// testing original mount point, make sure the mount link is valid
_, err := ioutil.ReadDir(target)
_, err := os.ReadDir(target)
if err == nil {
klog.V(2).Infof("already mounted to target %s", target)
return !notMnt, nil
Expand Down
3 changes: 1 addition & 2 deletions pkg/smb/smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package smb

import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestNewFakeDriver(t *testing.T) {
}

func TestIsCorruptedDir(t *testing.T) {
existingMountPath, err := ioutil.TempDir(os.TempDir(), "csi-mount-test")
existingMountPath, err := os.MkdirTemp(os.TempDir(), "csi-mount-test")
if err != nil {
t.Fatalf("failed to create tmp dir: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions test/utils/credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package credentials
import (
"fmt"
"html/template"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -159,7 +158,7 @@ func DeleteAzureCredentialFile() error {
// getCredentialsFromAzureCredentials parses the azure credentials toml (AZURE_CREDENTIALS)
// in Prow and returns the credential information usable to Azure File CSI driver
func getCredentialsFromAzureCredentials(azureCredentialsPath string) (*FromProw, error) {
content, err := ioutil.ReadFile(azureCredentialsPath)
content, err := os.ReadFile(azureCredentialsPath)
log.Printf("Reading credentials file %v", azureCredentialsPath)
if err != nil {
return nil, fmt.Errorf("error reading credentials file %v %v", azureCredentialsPath, err)
Expand Down
7 changes: 3 additions & 4 deletions test/utils/credentials/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package credentials

import (
"bytes"
"io/ioutil"
"os"
"testing"
"text/template"
Expand Down Expand Up @@ -83,7 +82,7 @@ func TestCreateAzureCredentialFileOnAzurePublicCloud(t *testing.T) {
}

func withAzureCredentials(t *testing.T, isAzureChinaCloud bool) {
tempFile, err := ioutil.TempFile("", "azure.toml")
tempFile, err := os.CreateTemp("", "azure.toml")
assert.NoError(t, err)
defer func() {
err := os.Remove(tempFile.Name())
Expand Down Expand Up @@ -117,7 +116,7 @@ func withAzureCredentials(t *testing.T, isAzureChinaCloud bool) {
assert.Equal(t, "test-resource-group", creds.ResourceGroup)
assert.Equal(t, "test-location", creds.Location)

azureCredentialFileContent, err := ioutil.ReadFile(TempAzureCredentialFilePath)
azureCredentialFileContent, err := os.ReadFile(TempAzureCredentialFilePath)
assert.NoError(t, err)

const expectedAzureCredentialFileContent = `
Expand Down Expand Up @@ -168,7 +167,7 @@ func withEnvironmentVariables(t *testing.T, isAzureChinaCloud bool) {
assert.Equal(t, "test-resource-group", creds.ResourceGroup)
assert.Equal(t, "test-location", creds.Location)

azureCredentialFileContent, err := ioutil.ReadFile(TempAzureCredentialFilePath)
azureCredentialFileContent, err := os.ReadFile(TempAzureCredentialFilePath)
assert.NoError(t, err)

const expectedAzureCredentialFileContent = `
Expand Down

0 comments on commit 862a138

Please sign in to comment.