cleanup: use os.ReadFile to read file

as ioutil.ReadFile is deprecated and
suggestion is to use os.ReadFile as
per https://pkg.go.dev/io/ioutil updating
the same.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2022-01-21 15:02:34 +05:30
committed by mergify[bot]
parent 562dff0d19
commit aba6979d29
10 changed files with 17 additions and 23 deletions

View File

@ -21,7 +21,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
@ -244,7 +243,7 @@ func GetKrbdSupportedFeatures() (string, error) {
return "", err
}
}
val, err := ioutil.ReadFile(krbdSupportedFeaturesFile)
val, err := os.ReadFile(krbdSupportedFeaturesFile)
if err != nil {
log.ErrorLogMsg("reading file %q failed: %v", krbdSupportedFeaturesFile, err)
@ -1638,7 +1637,7 @@ func lookupRBDImageMetadataStash(metaDataPath string) (rbdImageMetadataStash, er
var imgMeta rbdImageMetadataStash
fPath := filepath.Join(metaDataPath, stashFileName)
encodedBytes, err := ioutil.ReadFile(fPath) // #nosec - intended reading from fPath
encodedBytes, err := os.ReadFile(fPath) // #nosec - intended reading from fPath
if err != nil {
if !os.IsNotExist(err) {
return imgMeta, fmt.Errorf("failed to read stashed JSON image metadata from path (%s): %w", fPath, err)