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:
Jo
2022-08-10 13:37:51 +00:00
committed by GitHub
parent 4926767737
commit 062d255124
140 changed files with 462 additions and 492 deletions

View File

@@ -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

View File

@@ -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)
}