Skip to content

Commit

Permalink
Merge pull request #287 from Madhan-SWE/remove-ioutil
Browse files Browse the repository at this point in the history
io/util removed as deprected
  • Loading branch information
k8s-ci-robot authored Nov 7, 2022
2 parents 8f4c1e1 + 09ef662 commit c475d3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
9 changes: 4 additions & 5 deletions pkg/driver/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ limitations under the License.
package driver

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)

func TestMakeDir(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-powervs-csi")
dir, err := os.MkdirTemp("", "mount-powervs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
Expand All @@ -47,7 +46,7 @@ func TestMakeDir(t *testing.T) {

func TestMakeFile(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-powervs-csi")
dir, err := os.MkdirTemp("", "mount-powervs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
Expand All @@ -73,7 +72,7 @@ func TestMakeFile(t *testing.T) {

func TestExistsPath(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-powervs-csi")
dir, err := os.MkdirTemp("", "mount-powervs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
Expand All @@ -97,7 +96,7 @@ func TestExistsPath(t *testing.T) {

func TestGetDeviceName(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-powervs-csi")
dir, err := os.MkdirTemp("", "mount-powervs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/driver/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package driver
import (
"errors"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand All @@ -21,7 +20,7 @@ import (

func TestSanity(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "sanity-powervs-csi")
dir, err := os.MkdirTemp("", "sanity-powervs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/fibrechannel/fibrechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package fibrechannel

import (
"fmt"
"io/ioutil"
"os"
"os/exec"

Expand All @@ -31,7 +30,7 @@ import (
)

type ioHandler interface {
ReadDir(dirname string) ([]os.FileInfo, error)
ReadDir(dirname string) ([]os.DirEntry, error)
Lstat(name string) (os.FileInfo, error)
EvalSymlinks(path string) (string, error)
WriteFile(filename string, data []byte, perm os.FileMode) error
Expand All @@ -49,8 +48,8 @@ type Connector struct {
type OSioHandler struct{}

// ReadDir calls the ReadDir function from ioutil package
func (handler *OSioHandler) ReadDir(dirname string) ([]os.FileInfo, error) {
return ioutil.ReadDir(dirname)
func (handler *OSioHandler) ReadDir(dirname string) ([]os.DirEntry, error) {
return os.ReadDir(dirname)
}

// Lstat calls the Lstat function from os package
Expand All @@ -65,7 +64,7 @@ func (handler *OSioHandler) EvalSymlinks(path string) (string, error) {

// WriteFile calls WriteFile from ioutil package
func (handler *OSioHandler) WriteFile(filename string, data []byte, perm os.FileMode) error {
return ioutil.WriteFile(filename, data, perm)
return os.WriteFile(filename, data, perm)
}

// FindMultipathDeviceForDevice given a device name like /dev/sdx, find the devicemapper parent
Expand Down

0 comments on commit c475d3f

Please sign in to comment.