mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 06:02:18 +00:00
io/ioutil has already been deprecated in golang 1.16, so replace all ioutil with io and os
This commit is contained in:
@@ -24,7 +24,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -280,7 +279,7 @@ var _ = SIGDescribe("Kubectl client", func() {
|
||||
}
|
||||
framework.Logf("%s modified at %s (current time: %s)", path, info.ModTime(), time.Now())
|
||||
|
||||
data, readError := ioutil.ReadFile(path)
|
||||
data, readError := os.ReadFile(path)
|
||||
if readError != nil {
|
||||
framework.Logf("%s error: %v", path, readError)
|
||||
} else {
|
||||
@@ -691,11 +690,11 @@ var _ = SIGDescribe("Kubectl client", func() {
|
||||
|
||||
// Build a kubeconfig file that will make use of the injected ca and token,
|
||||
// but point at the DNS host and the default namespace
|
||||
tmpDir, err := ioutil.TempDir("", "icc-override")
|
||||
tmpDir, err := os.MkdirTemp("", "icc-override")
|
||||
overrideKubeconfigName := "icc-override.kubeconfig"
|
||||
framework.ExpectNoError(err)
|
||||
defer func() { os.Remove(tmpDir) }()
|
||||
framework.ExpectNoError(ioutil.WriteFile(filepath.Join(tmpDir, overrideKubeconfigName), []byte(`
|
||||
framework.ExpectNoError(os.WriteFile(filepath.Join(tmpDir, overrideKubeconfigName), []byte(`
|
||||
kind: Config
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
@@ -719,14 +718,14 @@ users:
|
||||
framework.Logf("copying override kubeconfig to the %s pod", simplePodName)
|
||||
framework.RunKubectlOrDie(ns, "cp", filepath.Join(tmpDir, overrideKubeconfigName), ns+"/"+simplePodName+":/tmp/")
|
||||
|
||||
framework.ExpectNoError(ioutil.WriteFile(filepath.Join(tmpDir, "invalid-configmap-with-namespace.yaml"), []byte(`
|
||||
framework.ExpectNoError(os.WriteFile(filepath.Join(tmpDir, "invalid-configmap-with-namespace.yaml"), []byte(`
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: "configmap with namespace and invalid name"
|
||||
namespace: configmap-namespace
|
||||
`), os.FileMode(0755)))
|
||||
framework.ExpectNoError(ioutil.WriteFile(filepath.Join(tmpDir, "invalid-configmap-without-namespace.yaml"), []byte(`
|
||||
framework.ExpectNoError(os.WriteFile(filepath.Join(tmpDir, "invalid-configmap-without-namespace.yaml"), []byte(`
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
@@ -1385,7 +1384,7 @@ metadata:
|
||||
ginkgo.It("should copy a file from a running Pod", func() {
|
||||
remoteContents := "foobar\n"
|
||||
podSource := fmt.Sprintf("%s:/root/foo/bar/foo.bar", busyboxPodName)
|
||||
tempDestination, err := ioutil.TempFile(os.TempDir(), "copy-foobar")
|
||||
tempDestination, err := os.CreateTemp(os.TempDir(), "copy-foobar")
|
||||
if err != nil {
|
||||
framework.Failf("Failed creating temporary destination file: %v", err)
|
||||
}
|
||||
@@ -1393,7 +1392,7 @@ metadata:
|
||||
ginkgo.By("specifying a remote filepath " + podSource + " on the pod")
|
||||
framework.RunKubectlOrDie(ns, "cp", podSource, tempDestination.Name())
|
||||
ginkgo.By("verifying that the contents of the remote file " + podSource + " have been copied to a local file " + tempDestination.Name())
|
||||
localData, err := ioutil.ReadAll(tempDestination)
|
||||
localData, err := io.ReadAll(tempDestination)
|
||||
if err != nil {
|
||||
framework.Failf("Failed reading temporary local file: %v", err)
|
||||
}
|
||||
@@ -1648,7 +1647,7 @@ metadata:
|
||||
*/
|
||||
framework.ConformanceIt("should support --unix-socket=/path ", func() {
|
||||
ginkgo.By("Starting the proxy")
|
||||
tmpdir, err := ioutil.TempDir("", "kubectl-proxy-unix")
|
||||
tmpdir, err := os.MkdirTemp("", "kubectl-proxy-unix")
|
||||
if err != nil {
|
||||
framework.Failf("Failed to create temporary directory: %v", err)
|
||||
}
|
||||
@@ -1958,7 +1957,7 @@ func curlTransport(url string, transport *http.Transport) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
@@ -231,7 +231,7 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
|
||||
}()
|
||||
|
||||
ginkgo.By("Reading data from the local port")
|
||||
fromServer, err := ioutil.ReadAll(conn)
|
||||
fromServer, err := io.ReadAll(conn)
|
||||
if err != nil {
|
||||
framework.Failf("Unexpected error reading data from the server: %v", err)
|
||||
}
|
||||
@@ -323,7 +323,7 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
|
||||
fmt.Fprint(conn, "abc")
|
||||
|
||||
ginkgo.By("Reading data from the local port")
|
||||
fromServer, err := ioutil.ReadAll(conn)
|
||||
fromServer, err := io.ReadAll(conn)
|
||||
if err != nil {
|
||||
framework.Failf("Unexpected error reading data from the server: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user