Skip to content

Commit

Permalink
Merge pull request #223 from SchSeba/golint
Browse files Browse the repository at this point in the history
Fix golint issue
  • Loading branch information
adrianchiris authored Sep 5, 2022
2 parents 54a4712 + fd19643 commit 921c28c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.45
version: v1.49
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions pkg/utils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package utils

import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
Expand Down Expand Up @@ -70,7 +69,7 @@ func CreateTmpSysFs() error {
originalRoot, _ := os.Open("/")
ts.originalRoot = originalRoot

tmpdir, err := ioutil.TempDir("/tmp", "sriovplugin-testfiles-")
tmpdir, err := os.MkdirTemp("/tmp", "sriovplugin-testfiles-")
if err != nil {
return err
}
Expand All @@ -85,7 +84,7 @@ func CreateTmpSysFs() error {
}

for filename, body := range ts.fileList {
if err := ioutil.WriteFile(filepath.Join(ts.dirRoot, filename), body, 0600); err != nil {
if err := os.WriteFile(filepath.Join(ts.dirRoot, filename), body, 0600); err != nil {
return err
}
}
Expand Down
15 changes: 7 additions & 8 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package utils
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -29,7 +28,7 @@ func GetSriovNumVfs(ifName string) (int, error) {
return vfTotal, fmt.Errorf("failed to open the sriov_numfs of device %q: %v", ifName, err)
}

data, err := ioutil.ReadFile(sriovFile)
data, err := os.ReadFile(sriovFile)
if err != nil {
return vfTotal, fmt.Errorf("failed to read the sriov_numfs of device %q: %v", ifName, err)
}
Expand Down Expand Up @@ -80,7 +79,7 @@ func GetPfName(vf string) (string, error) {
return "", err
}

files, err := ioutil.ReadDir(pfSymLink)
files, err := os.ReadDir(pfSymLink)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -129,7 +128,7 @@ func GetSharedPF(ifName string) (string, error) {

fullpath, _ := filepath.EvalSymlinks(pfDir)
parentDir := fullpath[:len(fullpath)-len(ifName)]
dirList, _ := ioutil.ReadDir(parentDir)
dirList, _ := os.ReadDir(parentDir)

for _, file := range dirList {
if file.Name() != ifName {
Expand All @@ -149,7 +148,7 @@ func GetVFLinkNames(pciAddr string) (string, error) {
return "", err
}

fInfos, err := ioutil.ReadDir(vfDir)
fInfos, err := os.ReadDir(vfDir)
if err != nil {
return "", fmt.Errorf("failed to read net dir of the device %s: %v", pciAddr, err)
}
Expand All @@ -174,7 +173,7 @@ func GetVFLinkNamesFromVFID(pfName string, vfID int) ([]string, error) {
return nil, err
}

fInfos, err := ioutil.ReadDir(vfDir)
fInfos, err := os.ReadDir(vfDir)
if err != nil {
return nil, fmt.Errorf("failed to read the virtfn%d dir of the device %q: %v", vfID, pfName, err)
}
Expand Down Expand Up @@ -233,7 +232,7 @@ func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {

path := filepath.Join(dataDir, containerID)

err := ioutil.WriteFile(path, netconf, 0600)
err := os.WriteFile(path, netconf, 0600)
if err != nil {
return fmt.Errorf("failed to write container data in the path(%q): %v", path, err)
}
Expand All @@ -243,7 +242,7 @@ func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {

// ReadScratchNetConf takes in container ID, Pod interface name and data dir as string and returns a pointer to Conf
func ReadScratchNetConf(cRefPath string) ([]byte, error) {
data, err := ioutil.ReadFile(cRefPath)
data, err := os.ReadFile(cRefPath)
if err != nil {
return nil, fmt.Errorf("failed to read container data in the path(%q): %v", cRefPath, err)
}
Expand Down

0 comments on commit 921c28c

Please sign in to comment.