mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	Merge pull request #112598 from wangguoyan/fix-deprecated-method
replace deprecated ioutil functions
This commit is contained in:
		| @@ -22,7 +22,6 @@ import ( | ||||
| 	"crypto/x509" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"time" | ||||
| @@ -243,7 +242,7 @@ func validateKubeConfig(outDir, filename string, config *clientcmdapi.Config) er | ||||
| 		// fallback to load CA cert data from external CA file | ||||
| 		clusterCAFilePath := currentConfig.Clusters[currentCluster].CertificateAuthority | ||||
| 		if len(clusterCAFilePath) > 0 { | ||||
| 			clusterCABytes, err := ioutil.ReadFile(clusterCAFilePath) | ||||
| 			clusterCABytes, err := os.ReadFile(clusterCAFilePath) | ||||
| 			if err != nil { | ||||
| 				klog.Warningf("failed to load CA cert from %q for kubeconfig %q, %v", clusterCAFilePath, kubeConfigFilePath, err) | ||||
| 			} else { | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import ( | ||||
| 	"crypto/x509" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"reflect" | ||||
| @@ -492,7 +491,7 @@ func TestValidateKubeConfig(t *testing.T) { | ||||
| 	if configWithSameClusterCaByExternalFile.Clusters[currentCtx.Cluster] == nil { | ||||
| 		t.Fatal("failed to find the given CurrentContext Cluster in Clusters of the kubeconfig") | ||||
| 	} | ||||
| 	tmpfile, err := ioutil.TempFile("", "external-ca.crt") | ||||
| 	tmpfile, err := os.CreateTemp("", "external-ca.crt") | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
|   | ||||
| @@ -20,7 +20,6 @@ import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| @@ -223,12 +222,12 @@ func CleanupKubeletDynamicEnvFileContainerRuntime(dryRun bool) error { | ||||
| 		return nil | ||||
| 	} | ||||
| 	klog.V(2).Infof("Ensuring that %q does not include a --container-runtime flag", filePath) | ||||
| 	bytes, err := ioutil.ReadFile(filePath) | ||||
| 	bytes, err := os.ReadFile(filePath) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrapf(err, "failed to read kubelet configuration from file %q", filePath) | ||||
| 	} | ||||
| 	updated := cleanupKubeletDynamicEnvFileContainerRuntime(string(bytes)) | ||||
| 	if err := ioutil.WriteFile(filePath, []byte(updated), 0644); err != nil { | ||||
| 	if err := os.WriteFile(filePath, []byte(updated), 0644); err != nil { | ||||
| 		return errors.Wrapf(err, "failed to write kubelet configuration to the file %q", filePath) | ||||
| 	} | ||||
| 	return nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot