mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 06:02:18 +00:00
replace deprecated io/ioutil with os and io for cmd
This commit is contained in:
@@ -18,7 +18,7 @@ package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -132,7 +132,7 @@ func isSysFSWritable() (bool, error) {
|
||||
}
|
||||
|
||||
func readIntStringFile(filename string) (int, error) {
|
||||
b, err := ioutil.ReadFile(filename)
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
@@ -140,5 +140,5 @@ func readIntStringFile(filename string) (int, error) {
|
||||
}
|
||||
|
||||
func writeIntStringFile(filename string, value int) error {
|
||||
return ioutil.WriteFile(filename, []byte(strconv.Itoa(value)), 0640)
|
||||
return os.WriteFile(filename, []byte(strconv.Itoa(value)), 0640)
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import (
|
||||
"errors"
|
||||
goflag "flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -403,7 +402,7 @@ func newLenientSchemeAndCodecs() (*runtime.Scheme, *serializer.CodecFactory, err
|
||||
// loadConfigFromFile loads the contents of file and decodes it as a
|
||||
// KubeProxyConfiguration object.
|
||||
func (o *Options) loadConfigFromFile(file string) (*kubeproxyconfig.KubeProxyConfiguration, error) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package app
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -406,7 +405,7 @@ func TestProcessHostnameOverrideFlag(t *testing.T) {
|
||||
|
||||
func TestConfigChange(t *testing.T) {
|
||||
setUp := func() (*os.File, string, error) {
|
||||
tempDir, err := ioutil.TempDir("", "kubeproxy-config-change")
|
||||
tempDir, err := os.MkdirTemp("", "kubeproxy-config-change")
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("unable to create temporary directory: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user