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:
@@ -3,7 +3,7 @@ package datasources
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -23,7 +23,7 @@ type configReader struct {
|
||||
func (cr *configReader) readConfig(ctx context.Context, path string) ([]*configs, error) {
|
||||
var datasources []*configs
|
||||
|
||||
files, err := ioutil.ReadDir(path)
|
||||
files, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
cr.log.Error("can't read datasource provisioning files from directory", "path", path, "error", err)
|
||||
return datasources, nil
|
||||
@@ -50,7 +50,7 @@ func (cr *configReader) readConfig(ctx context.Context, path string) ([]*configs
|
||||
return datasources, nil
|
||||
}
|
||||
|
||||
func (cr *configReader) parseDatasourceConfig(path string, file os.FileInfo) (*configs, error) {
|
||||
func (cr *configReader) parseDatasourceConfig(path string, file fs.DirEntry) (*configs, error) {
|
||||
filename, _ := filepath.Abs(filepath.Join(path, file.Name()))
|
||||
|
||||
// nolint:gosec
|
||||
|
||||
Reference in New Issue
Block a user