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 notifiers
import (
"context"
"fmt"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"strings"
@@ -29,7 +29,7 @@ func (cr *configReader) readConfig(ctx context.Context, path string) ([]*notific
var notifications []*notificationsAsConfig
cr.log.Debug("Looking for alert notification provisioning files", "path", path)
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
cr.log.Error("Can't read alert notification provisioning files from directory", "path", path, "error", err)
return notifications, nil
@@ -65,7 +65,7 @@ func (cr *configReader) readConfig(ctx context.Context, path string) ([]*notific
return notifications, nil
}
func (cr *configReader) parseNotificationConfig(path string, file os.FileInfo) (*notificationsAsConfig, error) {
func (cr *configReader) parseNotificationConfig(path string, file fs.DirEntry) (*notificationsAsConfig, error) {
filename, _ := filepath.Abs(filepath.Join(path, file.Name()))
// nolint:gosec