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,8 +3,8 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ func main() {
|
||||
}
|
||||
|
||||
//nolint
|
||||
b, err := ioutil.ReadFile(input)
|
||||
b, err := os.ReadFile(input)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(output, out, 0644)
|
||||
err = os.WriteFile(output, out, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package definitions
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -808,10 +808,10 @@ alertmanager_config: |
|
||||
func Test_GettableUserConfigRoundtrip(t *testing.T) {
|
||||
// raw contains secret fields. We'll unmarshal, re-marshal, and ensure
|
||||
// the fields are not redacted.
|
||||
yamlEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.yaml")
|
||||
yamlEncoded, err := os.ReadFile("alertmanager_test_artifact.yaml")
|
||||
require.Nil(t, err)
|
||||
|
||||
jsonEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.json")
|
||||
jsonEncoded, err := os.ReadFile("alertmanager_test_artifact.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
// test GettableUserConfig (yamlDecode -> jsonEncode)
|
||||
@@ -1031,7 +1031,7 @@ routes:
|
||||
}
|
||||
|
||||
func Test_Marshaling_Validation(t *testing.T) {
|
||||
jsonEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.json")
|
||||
jsonEncoded, err := os.ReadFile("alertmanager_test_artifact.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
var tmp GettableUserConfig
|
||||
|
||||
Reference in New Issue
Block a user