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