Remove ioutil.ReadDir from usage (#53550)

* add depguard rule for ioutil

* replace ioutil.ReadDir with os.ReadDir

* use legacy option in depguard supported in golangci-lint v1.40

* replace ioutil.ReadDir with os.ReadDir

* return error for file info
This commit is contained in:
Jo
2022-08-11 07:21:12 -04:00
committed by GitHub
parent b42f3e2c4c
commit ca72cd570e
18 changed files with 62 additions and 46 deletions
@@ -3,7 +3,7 @@ package plugins
import (
"context"
"fmt"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"strings"
@@ -30,7 +30,7 @@ func (cr *configReaderImpl) readConfig(ctx context.Context, path string) ([]*plu
var apps []*pluginsAsConfig
cr.log.Debug("Looking for plugin provisioning files", "path", path)
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
cr.log.Error("Failed to read plugin provisioning files from directory", "path", path, "error", err)
return apps, nil
@@ -65,7 +65,7 @@ func (cr *configReaderImpl) readConfig(ctx context.Context, path string) ([]*plu
return apps, nil
}
func (cr *configReaderImpl) parsePluginConfig(path string, file os.FileInfo) (*pluginsAsConfig, error) {
func (cr *configReaderImpl) parsePluginConfig(path string, file fs.DirEntry) (*pluginsAsConfig, error) {
filename, err := filepath.Abs(filepath.Join(path, file.Name()))
if err != nil {
return nil, err