mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile * replace ioutil.ReadAll -> io.ReadAll * replace ioutil.TempFile -> os.CreateTemp * replace ioutil.NopCloser -> io.NopCloser * replace ioutil.WriteFile -> os.WriteFile * replace ioutil.TempDir -> os.MkdirTemp * replace ioutil.Discard -> io.Discard
This commit is contained in:
@@ -3,7 +3,7 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -19,7 +19,7 @@ func loadTestJson(t testing.TB, file string) []byte {
|
||||
t.Helper()
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(filepath.Join("testdata", file+".json"))
|
||||
content, err := os.ReadFile(filepath.Join("testdata", file+".json"))
|
||||
require.NoError(t, err, "expected to be able to read file")
|
||||
require.True(t, len(content) > 0)
|
||||
return content
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -240,7 +239,7 @@ func (f *FileStorage) readRules() (ChannelRules, error) {
|
||||
ruleFile := f.ruleFilePath()
|
||||
// Safe to ignore gosec warning G304.
|
||||
// nolint:gosec
|
||||
ruleBytes, err := ioutil.ReadFile(ruleFile)
|
||||
ruleBytes, err := os.ReadFile(ruleFile)
|
||||
if err != nil {
|
||||
return ChannelRules{}, fmt.Errorf("can't read pipeline rules: %s: %w", f.ruleFilePath(), err)
|
||||
}
|
||||
@@ -309,7 +308,7 @@ func (f *FileStorage) readWriteConfigs() (WriteConfigs, error) {
|
||||
filePath := f.writeConfigsFilePath()
|
||||
// Safe to ignore gosec warning G304.
|
||||
// nolint:gosec
|
||||
bytes, err := ioutil.ReadFile(filePath)
|
||||
bytes, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return WriteConfigs{}, fmt.Errorf("can't read %s file: %w", filePath, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user