mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	replace deprecated io/ioutil with os and io for cmd
This commit is contained in:
		| @@ -18,7 +18,7 @@ package main | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"k8s.io/cli-runtime/pkg/genericclioptions" | 	"k8s.io/cli-runtime/pkg/genericclioptions" | ||||||
| @@ -29,7 +29,7 @@ import ( | |||||||
| func main() { | func main() { | ||||||
| 	var errorCount int | 	var errorCount int | ||||||
|  |  | ||||||
| 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: ioutil.Discard, ErrOut: ioutil.Discard}}) | 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: io.Discard, ErrOut: io.Discard}}) | ||||||
| 	errors := cmdsanity.RunCmdChecks(kubectl, cmdsanity.AllCmdChecks, []string{}) | 	errors := cmdsanity.RunCmdChecks(kubectl, cmdsanity.AllCmdChecks, []string{}) | ||||||
| 	for _, err := range errors { | 	for _, err := range errors { | ||||||
| 		errorCount++ | 		errorCount++ | ||||||
|   | |||||||
| @@ -25,8 +25,8 @@ import ( | |||||||
| 	"flag" | 	"flag" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"log" | 	"log" | ||||||
|  | 	"os" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -65,7 +65,7 @@ func main() { | |||||||
| 			log.Fatalf("Error compiling excluded package regex: %v", err) | 			log.Fatalf("Error compiling excluded package regex: %v", err) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	b, err := ioutil.ReadFile(args[0]) | 	b, err := os.ReadFile(args[0]) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Fatalf("Error reading dependencies file: %v", err) | 		log.Fatalf("Error reading dependencies file: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"log" | 	"log" | ||||||
| 	"os" | 	"os" | ||||||
| 	"os/exec" | 	"os/exec" | ||||||
| @@ -81,7 +80,7 @@ func runCommand(cmd ...string) (string, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func readFile(path string) (string, error) { | func readFile(path string) (string, error) { | ||||||
| 	content, err := ioutil.ReadFile(path) | 	content, err := os.ReadFile(path) | ||||||
| 	// Convert []byte to string and print to screen | 	// Convert []byte to string and print to screen | ||||||
| 	return string(content), err | 	return string(content), err | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"github.com/spf13/cobra/doc" | 	"github.com/spf13/cobra/doc" | ||||||
| @@ -47,6 +47,6 @@ func main() { | |||||||
| 	// Set environment variables used by kubectl so the output is consistent, | 	// Set environment variables used by kubectl so the output is consistent, | ||||||
| 	// regardless of where we run. | 	// regardless of where we run. | ||||||
| 	os.Setenv("HOME", "/home/username") | 	os.Setenv("HOME", "/home/username") | ||||||
| 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: ioutil.Discard, ErrOut: ioutil.Discard}}) | 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: io.Discard, ErrOut: io.Discard}}) | ||||||
| 	doc.GenMarkdownTree(kubectl, outDir) | 	doc.GenMarkdownTree(kubectl, outDir) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"github.com/spf13/cobra/doc" | 	"github.com/spf13/cobra/doc" | ||||||
| @@ -79,7 +79,7 @@ func main() { | |||||||
| 		pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) | 		pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) | ||||||
|  |  | ||||||
| 		// generate docs for kubeadm | 		// generate docs for kubeadm | ||||||
| 		kubeadm := kubeadmapp.NewKubeadmCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard) | 		kubeadm := kubeadmapp.NewKubeadmCommand(bytes.NewReader(nil), io.Discard, io.Discard) | ||||||
| 		doc.GenMarkdownTree(kubeadm, outDir) | 		doc.GenMarkdownTree(kubeadm, outDir) | ||||||
|  |  | ||||||
| 		// cleanup generated code for usage as include in the website | 		// cleanup generated code for usage as include in the website | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -38,14 +38,14 @@ func MarkdownPostProcessing(cmd *cobra.Command, dir string, processor func(strin | |||||||
| 	basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md" | 	basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md" | ||||||
| 	filename := filepath.Join(dir, basename) | 	filename := filepath.Join(dir, basename) | ||||||
|  |  | ||||||
| 	markdownBytes, err := ioutil.ReadFile(filename) | 	markdownBytes, err := os.ReadFile(filename) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	processedMarkDown := processor(string(markdownBytes)) | 	processedMarkDown := processor(string(markdownBytes)) | ||||||
|  |  | ||||||
| 	return ioutil.WriteFile(filename, []byte(processedMarkDown), 0644) | 	return os.WriteFile(filename, []byte(processedMarkDown), 0644) | ||||||
| } | } | ||||||
|  |  | ||||||
| // cleanupForInclude parts of markdown that will make difficult to use it as include in the website: | // cleanupForInclude parts of markdown that will make difficult to use it as include in the website: | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -97,14 +97,14 @@ func main() { | |||||||
| 		} | 		} | ||||||
| 	case "kubectl": | 	case "kubectl": | ||||||
| 		// generate manpage for kubectl | 		// generate manpage for kubectl | ||||||
| 		kubectl := kubectlcmd.NewKubectlCommand(kubectlcmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: ioutil.Discard, ErrOut: ioutil.Discard}}) | 		kubectl := kubectlcmd.NewKubectlCommand(kubectlcmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: io.Discard, ErrOut: io.Discard}}) | ||||||
| 		genMarkdown(kubectl, "", outDir) | 		genMarkdown(kubectl, "", outDir) | ||||||
| 		for _, c := range kubectl.Commands() { | 		for _, c := range kubectl.Commands() { | ||||||
| 			genMarkdown(c, "kubectl", outDir) | 			genMarkdown(c, "kubectl", outDir) | ||||||
| 		} | 		} | ||||||
| 	case "kubeadm": | 	case "kubeadm": | ||||||
| 		// generate manpage for kubeadm | 		// generate manpage for kubeadm | ||||||
| 		kubeadm := kubeadmapp.NewKubeadmCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard) | 		kubeadm := kubeadmapp.NewKubeadmCommand(bytes.NewReader(nil), io.Discard, io.Discard) | ||||||
| 		genMarkdown(kubeadm, "", outDir) | 		genMarkdown(kubeadm, "", outDir) | ||||||
| 		for _, c := range kubeadm.Commands() { | 		for _, c := range kubeadm.Commands() { | ||||||
| 			genMarkdown(c, "kubeadm", outDir) | 			genMarkdown(c, "kubeadm", outDir) | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -66,7 +66,7 @@ func main() { | |||||||
| 	// Set environment variables used by kubectl so the output is consistent, | 	// Set environment variables used by kubectl so the output is consistent, | ||||||
| 	// regardless of where we run. | 	// regardless of where we run. | ||||||
| 	os.Setenv("HOME", "/home/username") | 	os.Setenv("HOME", "/home/username") | ||||||
| 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: ioutil.Discard, ErrOut: ioutil.Discard}}) | 	kubectl := cmd.NewKubectlCommand(cmd.KubectlOptions{IOStreams: genericclioptions.IOStreams{In: bytes.NewReader(nil), Out: io.Discard, ErrOut: io.Discard}}) | ||||||
| 	genYaml(kubectl, "", outDir) | 	genYaml(kubectl, "", outDir) | ||||||
| 	for _, c := range kubectl.Commands() { | 	for _, c := range kubectl.Commands() { | ||||||
| 		genYaml(c, "kubectl", outDir) | 		genYaml(c, "kubectl", outDir) | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"log" | 	"log" | ||||||
| 	"os" | 	"os" | ||||||
| 	"os/exec" | 	"os/exec" | ||||||
| @@ -216,7 +215,7 @@ func main() { | |||||||
| } | } | ||||||
|  |  | ||||||
| func loadImportRestrictions(configFile string) ([]ImportRestriction, error) { | func loadImportRestrictions(configFile string) ([]ImportRestriction, error) { | ||||||
| 	config, err := ioutil.ReadFile(configFile) | 	config, err := os.ReadFile(configFile) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, fmt.Errorf("failed to load configuration from %s: %v", configFile, err) | 		return nil, fmt.Errorf("failed to load configuration from %s: %v", configFile, err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package testing | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| @@ -127,7 +126,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo | |||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| 	result.TmpDir, err = ioutil.TempDir("", "kubernetes-kube-apiserver") | 	result.TmpDir, err = os.MkdirTemp("", "kubernetes-kube-apiserver") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return result, fmt.Errorf("failed to create temp dir: %v", err) | 		return result, fmt.Errorf("failed to create temp dir: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -156,7 +155,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo | |||||||
| 			return result, err | 			return result, err | ||||||
| 		} | 		} | ||||||
| 		proxyCACertFile := path.Join(s.SecureServing.ServerCert.CertDirectory, "proxy-ca.crt") | 		proxyCACertFile := path.Join(s.SecureServing.ServerCert.CertDirectory, "proxy-ca.crt") | ||||||
| 		if err := ioutil.WriteFile(proxyCACertFile, testutil.EncodeCertPEM(proxySigningCert), 0644); err != nil { | 		if err := os.WriteFile(proxyCACertFile, testutil.EncodeCertPEM(proxySigningCert), 0644); err != nil { | ||||||
| 			return result, err | 			return result, err | ||||||
| 		} | 		} | ||||||
| 		s.Authentication.RequestHeader.ClientCAFile = proxyCACertFile | 		s.Authentication.RequestHeader.ClientCAFile = proxyCACertFile | ||||||
| @@ -169,7 +168,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo | |||||||
| 			return result, err | 			return result, err | ||||||
| 		} | 		} | ||||||
| 		clientCACertFile := path.Join(s.SecureServing.ServerCert.CertDirectory, "client-ca.crt") | 		clientCACertFile := path.Join(s.SecureServing.ServerCert.CertDirectory, "client-ca.crt") | ||||||
| 		if err := ioutil.WriteFile(clientCACertFile, testutil.EncodeCertPEM(clientSigningCert), 0644); err != nil { | 		if err := os.WriteFile(clientCACertFile, testutil.EncodeCertPEM(clientSigningCert), 0644); err != nil { | ||||||
| 			return result, err | 			return result, err | ||||||
| 		} | 		} | ||||||
| 		s.Authentication.ClientCert.ClientCA = clientCACertFile | 		s.Authentication.ClientCert.ClientCA = clientCACertFile | ||||||
| @@ -191,12 +190,12 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo | |||||||
| 		return result, err | 		return result, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	saSigningKeyFile, err := ioutil.TempFile("/tmp", "insecure_test_key") | 	saSigningKeyFile, err := os.CreateTemp("/tmp", "insecure_test_key") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("create temp file failed: %v", err) | 		t.Fatalf("create temp file failed: %v", err) | ||||||
| 	} | 	} | ||||||
| 	defer os.RemoveAll(saSigningKeyFile.Name()) | 	defer os.RemoveAll(saSigningKeyFile.Name()) | ||||||
| 	if err = ioutil.WriteFile(saSigningKeyFile.Name(), []byte(ecdsaPrivateKey), 0666); err != nil { | 	if err = os.WriteFile(saSigningKeyFile.Name(), []byte(ecdsaPrivateKey), 0666); err != nil { | ||||||
| 		t.Fatalf("write file %s failed: %v", saSigningKeyFile.Name(), err) | 		t.Fatalf("write file %s failed: %v", saSigningKeyFile.Name(), err) | ||||||
| 	} | 	} | ||||||
| 	s.ServiceAccountSigningKeyFile = saSigningKeyFile.Name() | 	s.ServiceAccountSigningKeyFile = saSigningKeyFile.Name() | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ package app | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -646,7 +645,7 @@ func (c serviceAccountTokenControllerStarter) startServiceAccountTokenController | |||||||
| } | } | ||||||
|  |  | ||||||
| func readCA(file string) ([]byte, error) { | func readCA(file string) ([]byte, error) { | ||||||
| 	rootCA, err := ioutil.ReadFile(file) | 	rootCA, err := os.ReadFile(file) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package testing | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"time" | 	"time" | ||||||
| @@ -73,7 +72,7 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err | |||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| 	result.TmpDir, err = ioutil.TempDir("", "kube-controller-manager") | 	result.TmpDir, err = os.MkdirTemp("", "kube-controller-manager") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return result, fmt.Errorf("failed to create temp dir: %v", err) | 		return result, fmt.Errorf("failed to create temp dir: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ package app | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -132,7 +132,7 @@ func isSysFSWritable() (bool, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func readIntStringFile(filename string) (int, error) { | func readIntStringFile(filename string) (int, error) { | ||||||
| 	b, err := ioutil.ReadFile(filename) | 	b, err := os.ReadFile(filename) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return -1, err | 		return -1, err | ||||||
| 	} | 	} | ||||||
| @@ -140,5 +140,5 @@ func readIntStringFile(filename string) (int, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func writeIntStringFile(filename string, value 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" | 	"errors" | ||||||
| 	goflag "flag" | 	goflag "flag" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -403,7 +402,7 @@ func newLenientSchemeAndCodecs() (*runtime.Scheme, *serializer.CodecFactory, err | |||||||
| // loadConfigFromFile loads the contents of file and decodes it as a | // loadConfigFromFile loads the contents of file and decodes it as a | ||||||
| // KubeProxyConfiguration object. | // KubeProxyConfiguration object. | ||||||
| func (o *Options) loadConfigFromFile(file string) (*kubeproxyconfig.KubeProxyConfiguration, error) { | func (o *Options) loadConfigFromFile(file string) (*kubeproxyconfig.KubeProxyConfiguration, error) { | ||||||
| 	data, err := ioutil.ReadFile(file) | 	data, err := os.ReadFile(file) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package app | |||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -406,7 +405,7 @@ func TestProcessHostnameOverrideFlag(t *testing.T) { | |||||||
|  |  | ||||||
| func TestConfigChange(t *testing.T) { | func TestConfigChange(t *testing.T) { | ||||||
| 	setUp := func() (*os.File, string, error) { | 	setUp := func() (*os.File, string, error) { | ||||||
| 		tempDir, err := ioutil.TempDir("", "kubeproxy-config-change") | 		tempDir, err := os.MkdirTemp("", "kubeproxy-config-change") | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, "", fmt.Errorf("unable to create temporary directory: %v", err) | 			return nil, "", fmt.Errorf("unable to create temporary directory: %v", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| @@ -32,7 +31,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func loadConfigFromFile(file string) (*config.KubeSchedulerConfiguration, error) { | func loadConfigFromFile(file string) (*config.KubeSchedulerConfiguration, error) { | ||||||
| 	data, err := ioutil.ReadFile(file) | 	data, err := os.ReadFile(file) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package options | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/http/httptest" | 	"net/http/httptest" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -46,7 +45,7 @@ import ( | |||||||
|  |  | ||||||
| func TestSchedulerOptions(t *testing.T) { | func TestSchedulerOptions(t *testing.T) { | ||||||
| 	// temp dir | 	// temp dir | ||||||
| 	tmpDir, err := ioutil.TempDir("", "scheduler-options") | 	tmpDir, err := os.MkdirTemp("", "scheduler-options") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| @@ -78,7 +77,7 @@ func TestSchedulerOptions(t *testing.T) { | |||||||
| 	// config file and kubeconfig | 	// config file and kubeconfig | ||||||
| 	configFile := filepath.Join(tmpDir, "scheduler.yaml") | 	configFile := filepath.Join(tmpDir, "scheduler.yaml") | ||||||
| 	configKubeconfig := filepath.Join(tmpDir, "config.kubeconfig") | 	configKubeconfig := filepath.Join(tmpDir, "config.kubeconfig") | ||||||
| 	if err := ioutil.WriteFile(configFile, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(configFile, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -87,7 +86,7 @@ leaderElection: | |||||||
|   leaderElect: true`, configKubeconfig)), os.FileMode(0600)); err != nil { |   leaderElect: true`, configKubeconfig)), os.FileMode(0600)); err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| 	if err := ioutil.WriteFile(configKubeconfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(configKubeconfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: v1 | apiVersion: v1 | ||||||
| kind: Config | kind: Config | ||||||
| clusters: | clusters: | ||||||
| @@ -110,7 +109,7 @@ users: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	oldConfigFile := filepath.Join(tmpDir, "scheduler_old.yaml") | 	oldConfigFile := filepath.Join(tmpDir, "scheduler_old.yaml") | ||||||
| 	if err := ioutil.WriteFile(oldConfigFile, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(oldConfigFile, []byte(fmt.Sprintf(` | ||||||
| apiVersion: componentconfig/v1alpha1 | apiVersion: componentconfig/v1alpha1 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -121,7 +120,7 @@ leaderElection: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	v1beta2VersionConfig := filepath.Join(tmpDir, "scheduler_v1beta2_api_version.yaml") | 	v1beta2VersionConfig := filepath.Join(tmpDir, "scheduler_v1beta2_api_version.yaml") | ||||||
| 	if err := ioutil.WriteFile(v1beta2VersionConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(v1beta2VersionConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -132,7 +131,7 @@ leaderElection: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	unknownVersionConfig := filepath.Join(tmpDir, "scheduler_invalid_wrong_api_version.yaml") | 	unknownVersionConfig := filepath.Join(tmpDir, "scheduler_invalid_wrong_api_version.yaml") | ||||||
| 	if err := ioutil.WriteFile(unknownVersionConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(unknownVersionConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/unknown | apiVersion: kubescheduler.config.k8s.io/unknown | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -143,7 +142,7 @@ leaderElection: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	noVersionConfig := filepath.Join(tmpDir, "scheduler_invalid_no_version.yaml") | 	noVersionConfig := filepath.Join(tmpDir, "scheduler_invalid_no_version.yaml") | ||||||
| 	if err := ioutil.WriteFile(noVersionConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(noVersionConfig, []byte(fmt.Sprintf(` | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
|   kubeconfig: "%s" |   kubeconfig: "%s" | ||||||
| @@ -153,7 +152,7 @@ leaderElection: | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	unknownFieldConfig := filepath.Join(tmpDir, "scheduler_invalid_unknown_field.yaml") | 	unknownFieldConfig := filepath.Join(tmpDir, "scheduler_invalid_unknown_field.yaml") | ||||||
| 	if err := ioutil.WriteFile(unknownFieldConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(unknownFieldConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -165,7 +164,7 @@ foo: bar`, configKubeconfig)), os.FileMode(0600)); err != nil { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	duplicateFieldConfig := filepath.Join(tmpDir, "scheduler_invalid_duplicate_fields.yaml") | 	duplicateFieldConfig := filepath.Join(tmpDir, "scheduler_invalid_duplicate_fields.yaml") | ||||||
| 	if err := ioutil.WriteFile(duplicateFieldConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(duplicateFieldConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -178,7 +177,7 @@ leaderElection: | |||||||
|  |  | ||||||
| 	// flag-specified kubeconfig | 	// flag-specified kubeconfig | ||||||
| 	flagKubeconfig := filepath.Join(tmpDir, "flag.kubeconfig") | 	flagKubeconfig := filepath.Join(tmpDir, "flag.kubeconfig") | ||||||
| 	if err := ioutil.WriteFile(flagKubeconfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(flagKubeconfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: v1 | apiVersion: v1 | ||||||
| kind: Config | kind: Config | ||||||
| clusters: | clusters: | ||||||
| @@ -202,7 +201,7 @@ users: | |||||||
|  |  | ||||||
| 	// plugin config | 	// plugin config | ||||||
| 	pluginConfigFile := filepath.Join(tmpDir, "plugin.yaml") | 	pluginConfigFile := filepath.Join(tmpDir, "plugin.yaml") | ||||||
| 	if err := ioutil.WriteFile(pluginConfigFile, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(pluginConfigFile, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -233,7 +232,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// v1beta2 plugin config | 	// v1beta2 plugin config | ||||||
| 	v1beta2PluginConfigFile := filepath.Join(tmpDir, "v1beta2_plugin.yaml") | 	v1beta2PluginConfigFile := filepath.Join(tmpDir, "v1beta2_plugin.yaml") | ||||||
| 	if err := ioutil.WriteFile(v1beta2PluginConfigFile, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(v1beta2PluginConfigFile, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -264,7 +263,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// multiple profiles config | 	// multiple profiles config | ||||||
| 	multiProfilesConfig := filepath.Join(tmpDir, "multi-profiles.yaml") | 	multiProfilesConfig := filepath.Join(tmpDir, "multi-profiles.yaml") | ||||||
| 	if err := ioutil.WriteFile(multiProfilesConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(multiProfilesConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -291,7 +290,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// multiple profiles config | 	// multiple profiles config | ||||||
| 	v1beta2MultiProfilesConfig := filepath.Join(tmpDir, "v1beta2_multi-profiles.yaml") | 	v1beta2MultiProfilesConfig := filepath.Join(tmpDir, "v1beta2_multi-profiles.yaml") | ||||||
| 	if err := ioutil.WriteFile(v1beta2MultiProfilesConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(v1beta2MultiProfilesConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package app | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/http/httptest" | 	"net/http/httptest" | ||||||
| @@ -45,7 +44,7 @@ import ( | |||||||
|  |  | ||||||
| func TestSetup(t *testing.T) { | func TestSetup(t *testing.T) { | ||||||
| 	// temp dir | 	// temp dir | ||||||
| 	tmpDir, err := ioutil.TempDir("", "scheduler-options") | 	tmpDir, err := os.MkdirTemp("", "scheduler-options") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| @@ -59,7 +58,7 @@ func TestSetup(t *testing.T) { | |||||||
| 	defer server.Close() | 	defer server.Close() | ||||||
|  |  | ||||||
| 	configKubeconfig := filepath.Join(tmpDir, "config.kubeconfig") | 	configKubeconfig := filepath.Join(tmpDir, "config.kubeconfig") | ||||||
| 	if err := ioutil.WriteFile(configKubeconfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(configKubeconfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: v1 | apiVersion: v1 | ||||||
| kind: Config | kind: Config | ||||||
| clusters: | clusters: | ||||||
| @@ -83,7 +82,7 @@ users: | |||||||
|  |  | ||||||
| 	// plugin config | 	// plugin config | ||||||
| 	pluginConfigFilev1beta3 := filepath.Join(tmpDir, "pluginv1beta3.yaml") | 	pluginConfigFilev1beta3 := filepath.Join(tmpDir, "pluginv1beta3.yaml") | ||||||
| 	if err := ioutil.WriteFile(pluginConfigFilev1beta3, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(pluginConfigFilev1beta3, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -121,7 +120,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// plugin config | 	// plugin config | ||||||
| 	pluginConfigFilev1beta2 := filepath.Join(tmpDir, "pluginv1beta2.yaml") | 	pluginConfigFilev1beta2 := filepath.Join(tmpDir, "pluginv1beta2.yaml") | ||||||
| 	if err := ioutil.WriteFile(pluginConfigFilev1beta2, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(pluginConfigFilev1beta2, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -158,7 +157,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// multiple profiles config | 	// multiple profiles config | ||||||
| 	multiProfilesConfig := filepath.Join(tmpDir, "multi-profiles.yaml") | 	multiProfilesConfig := filepath.Join(tmpDir, "multi-profiles.yaml") | ||||||
| 	if err := ioutil.WriteFile(multiProfilesConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(multiProfilesConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta2 | apiVersion: kubescheduler.config.k8s.io/v1beta2 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -188,7 +187,7 @@ profiles: | |||||||
|  |  | ||||||
| 	// empty leader-election config | 	// empty leader-election config | ||||||
| 	emptyLeaderElectionConfig := filepath.Join(tmpDir, "empty-leader-election-config.yaml") | 	emptyLeaderElectionConfig := filepath.Join(tmpDir, "empty-leader-election-config.yaml") | ||||||
| 	if err := ioutil.WriteFile(emptyLeaderElectionConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(emptyLeaderElectionConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
| @@ -199,7 +198,7 @@ clientConnection: | |||||||
|  |  | ||||||
| 	// leader-election config | 	// leader-election config | ||||||
| 	leaderElectionConfig := filepath.Join(tmpDir, "leader-election-config.yaml") | 	leaderElectionConfig := filepath.Join(tmpDir, "leader-election-config.yaml") | ||||||
| 	if err := ioutil.WriteFile(leaderElectionConfig, []byte(fmt.Sprintf(` | 	if err := os.WriteFile(leaderElectionConfig, []byte(fmt.Sprintf(` | ||||||
| apiVersion: kubescheduler.config.k8s.io/v1beta3 | apiVersion: kubescheduler.config.k8s.io/v1beta3 | ||||||
| kind: KubeSchedulerConfiguration | kind: KubeSchedulerConfiguration | ||||||
| clientConnection: | clientConnection: | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package testing | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"time" | 	"time" | ||||||
| @@ -75,7 +74,7 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err | |||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| 	result.TmpDir, err = ioutil.TempDir("", "kube-scheduler") | 	result.TmpDir, err = os.MkdirTemp("", "kube-scheduler") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return result, fmt.Errorf("failed to create temp dir: %v", err) | 		return result, fmt.Errorf("failed to create temp dir: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package validation | package validation | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| @@ -926,7 +925,7 @@ func TestValidateDiscoveryTokenAPIServer(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestValidateDiscoveryKubeConfigPath(t *testing.T) { | func TestValidateDiscoveryKubeConfigPath(t *testing.T) { | ||||||
| 	tmpfile, err := ioutil.TempFile("/tmp", "test_discovery_file") | 	tmpfile, err := os.CreateTemp("/tmp", "test_discovery_file") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Error creating temporary file: %v", err) | 		t.Errorf("Error creating temporary file: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"sort" | 	"sort" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -246,7 +246,7 @@ func newCmdConfigMigrate(out io.Writer) *cobra.Command { | |||||||
| 				return errors.New("the --old-config flag is mandatory") | 				return errors.New("the --old-config flag is mandatory") | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			oldCfgBytes, err := ioutil.ReadFile(oldCfgPath) | 			oldCfgBytes, err := os.ReadFile(oldCfgPath) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| @@ -259,7 +259,7 @@ func newCmdConfigMigrate(out io.Writer) *cobra.Command { | |||||||
| 			if newCfgPath == "" { | 			if newCfgPath == "" { | ||||||
| 				fmt.Fprint(out, string(outputBytes)) | 				fmt.Fprint(out, string(outputBytes)) | ||||||
| 			} else { | 			} else { | ||||||
| 				if err := ioutil.WriteFile(newCfgPath, outputBytes, 0644); err != nil { | 				if err := os.WriteFile(newCfgPath, outputBytes, 0644); err != nil { | ||||||
| 					return errors.Wrapf(err, "failed to write the new configuration to the file %q", newCfgPath) | 					return errors.Wrapf(err, "failed to write the new configuration to the file %q", newCfgPath) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -111,14 +110,14 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) { | |||||||
|  |  | ||||||
| 	for _, tc := range testcases { | 	for _, tc := range testcases { | ||||||
| 		t.Run(tc.name, func(t *testing.T) { | 		t.Run(tc.name, func(t *testing.T) { | ||||||
| 			tmpDir, err := ioutil.TempDir("", "kubeadm-images-test") | 			tmpDir, err := os.MkdirTemp("", "kubeadm-images-test") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("Unable to create temporary directory: %v", err) | 				t.Fatalf("Unable to create temporary directory: %v", err) | ||||||
| 			} | 			} | ||||||
| 			defer os.RemoveAll(tmpDir) | 			defer os.RemoveAll(tmpDir) | ||||||
|  |  | ||||||
| 			configFilePath := filepath.Join(tmpDir, "test-config-file") | 			configFilePath := filepath.Join(tmpDir, "test-config-file") | ||||||
| 			if err := ioutil.WriteFile(configFilePath, tc.configContents, 0644); err != nil { | 			if err := os.WriteFile(configFilePath, tc.configContents, 0644); err != nil { | ||||||
| 				t.Fatalf("Failed writing a config file: %v", err) | 				t.Fatalf("Failed writing a config file: %v", err) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @@ -413,12 +412,12 @@ func TestMigrate(t *testing.T) { | |||||||
| // Returns the name of the file created and a cleanup callback | // Returns the name of the file created and a cleanup callback | ||||||
| func tempConfig(t *testing.T, config []byte) (string, func()) { | func tempConfig(t *testing.T, config []byte) (string, func()) { | ||||||
| 	t.Helper() | 	t.Helper() | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-migration-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-migration-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Unable to create temporary directory: %v", err) | 		t.Fatalf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
| 	configFilePath := filepath.Join(tmpDir, "test-config-file") | 	configFilePath := filepath.Join(tmpDir, "test-config-file") | ||||||
| 	if err := ioutil.WriteFile(configFilePath, config, 0644); err != nil { | 	if err := os.WriteFile(configFilePath, config, 0644); err != nil { | ||||||
| 		os.RemoveAll(tmpDir) | 		os.RemoveAll(tmpDir) | ||||||
| 		t.Fatalf("Failed writing a config file: %v", err) | 		t.Fatalf("Failed writing a config file: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package cmd | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -50,7 +49,7 @@ controlPlaneEndpoint: "3.4.5.6" | |||||||
|  |  | ||||||
| func TestNewInitData(t *testing.T) { | func TestNewInitData(t *testing.T) { | ||||||
| 	// create temp directory | 	// create temp directory | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-init-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-init-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Unable to create temporary directory: %v", err) | 		t.Errorf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package cmd | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -47,7 +46,7 @@ nodeRegistration: | |||||||
|  |  | ||||||
| func TestNewJoinData(t *testing.T) { | func TestNewJoinData(t *testing.T) { | ||||||
| 	// create temp directory | 	// create temp directory | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-join-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-join-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Unable to create temporary directory: %v", err) | 		t.Errorf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package cmd | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -70,7 +69,7 @@ func generateTestKubeadmConfig(dir, id, certDir, clusterName string) (string, er | |||||||
| 	} | 	} | ||||||
| 	buf.Write(data) | 	buf.Write(data) | ||||||
|  |  | ||||||
| 	err = ioutil.WriteFile(cfgPath, buf.Bytes(), 0644) | 	err = os.WriteFile(cfgPath, buf.Bytes(), 0644) | ||||||
| 	return cfgPath, err | 	return cfgPath, err | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package phases | package phases | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -150,7 +149,7 @@ func TestConfigDirCleaner(t *testing.T) { | |||||||
| 			t.Logf("Running test: %s", name) | 			t.Logf("Running test: %s", name) | ||||||
|  |  | ||||||
| 			// Create a temporary directory for our fake config dir: | 			// Create a temporary directory for our fake config dir: | ||||||
| 			tmpDir, err := ioutil.TempDir("", "kubeadm-reset-test") | 			tmpDir, err := os.MkdirTemp("", "kubeadm-reset-test") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Errorf("Unable to create temporary directory: %s", err) | 				t.Errorf("Unable to create temporary directory: %s", err) | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package phases | package phases | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -104,7 +103,7 @@ func TestGetEtcdDataDir(t *testing.T) { | |||||||
|  |  | ||||||
| 			manifestPath := filepath.Join(tmpdir, "etcd.yaml") | 			manifestPath := filepath.Join(tmpdir, "etcd.yaml") | ||||||
| 			if test.writeManifest { | 			if test.writeManifest { | ||||||
| 				err := ioutil.WriteFile(manifestPath, []byte(test.podYaml), 0644) | 				err := os.WriteFile(manifestPath, []byte(test.podYaml), 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf(dedent.Dedent("failed to write pod manifest\n%s\n\tfatal error: %v"), name, err) | 					t.Fatalf(dedent.Dedent("failed to write pod manifest\n%s\n\tfatal error: %v"), name, err) | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ limitations under the License. | |||||||
| package phases | package phases | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"syscall" | 	"syscall" | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ import ( | |||||||
|  |  | ||||||
| // unmountKubeletDirectory unmounts all paths that contain KubeletRunDirectory | // unmountKubeletDirectory unmounts all paths that contain KubeletRunDirectory | ||||||
| func unmountKubeletDirectory(absoluteKubeletRunDirectory string) error { | func unmountKubeletDirectory(absoluteKubeletRunDirectory string) error { | ||||||
| 	raw, err := ioutil.ReadFile("/proc/mounts") | 	raw, err := os.ReadFile("/proc/mounts") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package cmd | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| @@ -200,7 +199,7 @@ func TestNewCmdToken(t *testing.T) { | |||||||
| 	var buf, bufErr bytes.Buffer | 	var buf, bufErr bytes.Buffer | ||||||
| 	testConfigTokenFile := "test-config-file" | 	testConfigTokenFile := "test-config-file" | ||||||
|  |  | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-token-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-token-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Unable to create temporary directory: %v", err) | 		t.Errorf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -268,7 +267,7 @@ func TestNewCmdToken(t *testing.T) { | |||||||
| func TestGetClientset(t *testing.T) { | func TestGetClientset(t *testing.T) { | ||||||
| 	testConfigTokenFile := "test-config-file" | 	testConfigTokenFile := "test-config-file" | ||||||
|  |  | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-token-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-token-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Unable to create temporary directory: %v", err) | 		t.Errorf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -304,7 +303,7 @@ func TestGetClientset(t *testing.T) { | |||||||
| func TestRunDeleteTokens(t *testing.T) { | func TestRunDeleteTokens(t *testing.T) { | ||||||
| 	var buf bytes.Buffer | 	var buf bytes.Buffer | ||||||
|  |  | ||||||
| 	tmpDir, err := ioutil.TempDir("", "kubeadm-token-test") | 	tmpDir, err := os.MkdirTemp("", "kubeadm-token-test") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Unable to create temporary directory: %v", err) | 		t.Errorf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| @@ -76,7 +75,7 @@ func loadConfig(cfgPath string, client clientset.Interface, skipComponentConfigs | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Otherwise, we have a config file. Let's load it. | 	// Otherwise, we have a config file. Let's load it. | ||||||
| 	configBytes, err := ioutil.ReadFile(cfgPath) | 	configBytes, err := os.ReadFile(cfgPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, false, errors.Wrapf(err, "unable to load config from file %q", cfgPath) | 		return nil, false, errors.Wrapf(err, "unable to load config from file %q", cfgPath) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package upgrade | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"github.com/pkg/errors" | 	"github.com/pkg/errors" | ||||||
| @@ -171,7 +170,7 @@ func runDiff(flags *diffFlags, args []string) error { | |||||||
| 		if path == "" { | 		if path == "" { | ||||||
| 			return errors.New("empty manifest path") | 			return errors.New("empty manifest path") | ||||||
| 		} | 		} | ||||||
| 		existingManifest, err := ioutil.ReadFile(path) | 		existingManifest, err := os.ReadFile(path) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ package upgrade | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func createTestRunDiffFile(contents []byte) (string, error) { | func createTestRunDiffFile(contents []byte) (string, error) { | ||||||
| 	file, err := ioutil.TempFile("", "kubeadm-upgrade-diff-config-*.yaml") | 	file, err := os.CreateTemp("", "kubeadm-upgrade-diff-config-*.yaml") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", errors.Wrap(err, "failed to create temporary test file") | 		return "", errors.Wrap(err, "failed to create temporary test file") | ||||||
| 	} | 	} | ||||||
| @@ -65,7 +65,7 @@ func TestRunDiff(t *testing.T) { | |||||||
|  |  | ||||||
| 	flags := &diffFlags{ | 	flags := &diffFlags{ | ||||||
| 		cfgPath: "", | 		cfgPath: "", | ||||||
| 		out:     ioutil.Discard, | 		out:     io.Discard, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// TODO: Add test cases for empty cfgPath, it should automatically fetch cfg from cluster | 	// TODO: Add test cases for empty cfgPath, it should automatically fetch cfg from cluster | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package upgrade | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"sort" | 	"sort" | ||||||
| 	"strings" | 	"strings" | ||||||
| @@ -185,7 +184,7 @@ func getComponentConfigVersionStates(cfg *kubeadmapi.ClusterConfiguration, clien | |||||||
| 	docmap := kubeadmapi.DocumentMap{} | 	docmap := kubeadmapi.DocumentMap{} | ||||||
|  |  | ||||||
| 	if cfgPath != "" { | 	if cfgPath != "" { | ||||||
| 		bytes, err := ioutil.ReadFile(cfgPath) | 		bytes, err := os.ReadFile(cfgPath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, errors.Wrapf(err, "unable to read config file %q", cfgPath) | 			return nil, errors.Wrapf(err, "unable to read config file %q", cfgPath) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package constants | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| @@ -608,7 +607,7 @@ func CreateTempDirForKubeadm(kubernetesDir, dirName string) (string, error) { | |||||||
| 		return "", errors.Wrapf(err, "failed to create directory %q", tempDir) | 		return "", errors.Wrapf(err, "failed to create directory %q", tempDir) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	tempDir, err := ioutil.TempDir(tempDir, dirName) | 	tempDir, err := os.MkdirTemp(tempDir, dirName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", errors.Wrap(err, "couldn't create a temporary directory") | 		return "", errors.Wrap(err, "couldn't create a temporary directory") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package https | package https | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -39,7 +39,7 @@ func RetrieveValidatedConfigInfo(httpsURL, clustername string, discoveryTimeout | |||||||
| 	} | 	} | ||||||
| 	defer response.Body.Close() | 	defer response.Body.Close() | ||||||
|  |  | ||||||
| 	kubeconfig, err := ioutil.ReadAll(response.Body) | 	kubeconfig, err := io.ReadAll(response.Body) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package clusterinfo | package clusterinfo | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"text/template" | 	"text/template" | ||||||
| @@ -80,7 +79,7 @@ func TestCreateBootstrapConfigMapIfNotExists(t *testing.T) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, server := range servers { | 	for _, server := range servers { | ||||||
| 		file, err := ioutil.TempFile("", "") | 		file, err := os.CreateTemp("", "") | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("could not create tempfile: %v", err) | 			t.Fatalf("could not create tempfile: %v", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"crypto" | 	"crypto" | ||||||
| 	"crypto/tls" | 	"crypto/tls" | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -145,7 +144,7 @@ func TestMakeCertTree(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestCreateCertificateChain(t *testing.T) { | func TestCreateCertificateChain(t *testing.T) { | ||||||
| 	dir, err := ioutil.TempDir("", t.Name()) | 	dir, err := os.MkdirTemp("", t.Name()) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
| 	"crypto" | 	"crypto" | ||||||
| 	"crypto/sha256" | 	"crypto/sha256" | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| @@ -264,7 +263,7 @@ func TestWriteCSRFilesIfNotExist(t *testing.T) { | |||||||
| 		{ | 		{ | ||||||
| 			name: "existing CSR is garbage", | 			name: "existing CSR is garbage", | ||||||
| 			setupFunc: func(csrPath string) error { | 			setupFunc: func(csrPath string) error { | ||||||
| 				return ioutil.WriteFile(path.Join(csrPath, "dummy.csr"), []byte("a--bunch--of-garbage"), os.ModePerm) | 				return os.WriteFile(path.Join(csrPath, "dummy.csr"), []byte("a--bunch--of-garbage"), os.ModePerm) | ||||||
| 			}, | 			}, | ||||||
| 			expectedError: true, | 			expectedError: true, | ||||||
| 		}, | 		}, | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package controlplane | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -164,7 +163,7 @@ func TestCreateStaticPodFilesWithPatches(t *testing.T) { | |||||||
| 	    patched: "true" | 	    patched: "true" | ||||||
| 	`) | 	`) | ||||||
|  |  | ||||||
| 	err = ioutil.WriteFile(filepath.Join(patchesPath, kubeadmconstants.KubeAPIServer+".yaml"), []byte(patchString), 0644) | 	err = os.WriteFile(filepath.Join(patchesPath, kubeadmconstants.KubeAPIServer+".yaml"), []byte(patchString), 0644) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("WriteFile returned unexpected error: %v", err) | 		t.Fatalf("WriteFile returned unexpected error: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package controlplane | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -507,7 +506,7 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { | |||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"encoding/hex" | 	"encoding/hex" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| 	"strings" | 	"strings" | ||||||
| @@ -173,7 +172,7 @@ func getSecretOwnerRef(client clientset.Interface, tokenID string) ([]metav1.Own | |||||||
| } | } | ||||||
|  |  | ||||||
| func loadAndEncryptCert(certPath string, key []byte) ([]byte, error) { | func loadAndEncryptCert(certPath string, key []byte) ([]byte, error) { | ||||||
| 	cert, err := ioutil.ReadFile(certPath) | 	cert, err := os.ReadFile(certPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package copycerts | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"encoding/hex" | 	"encoding/hex" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| @@ -61,7 +60,7 @@ func TestGetDataFromInitConfig(t *testing.T) { | |||||||
|  |  | ||||||
| 	certs := certsToTransfer(cfg) | 	certs := certsToTransfer(cfg) | ||||||
| 	for name, path := range certs { | 	for name, path := range certs { | ||||||
| 		if err := ioutil.WriteFile(path, certData, 0644); err != nil { | 		if err := os.WriteFile(path, certData, 0644); err != nil { | ||||||
| 			t.Fatalf(dedent.Dedent("failed to write cert: %s\nfatal error: %v"), name, err) | 			t.Fatalf(dedent.Dedent("failed to write cert: %s\nfatal error: %v"), name, err) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -191,7 +190,7 @@ func TestUploadCerts(t *testing.T) { | |||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("error decrypting secret data: %v", err) | 			t.Fatalf("error decrypting secret data: %v", err) | ||||||
| 		} | 		} | ||||||
| 		diskCertData, err := ioutil.ReadFile(certPath) | 		diskCertData, err := os.ReadFile(certPath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("error reading certificate from disk: %v", err) | 			t.Fatalf("error reading certificate from disk: %v", err) | ||||||
| 		} | 		} | ||||||
| @@ -235,7 +234,7 @@ func TestDownloadCerts(t *testing.T) { | |||||||
| 	const certFileMode = 0644 | 	const certFileMode = 0644 | ||||||
|  |  | ||||||
| 	for certName, certPath := range certsToTransfer(initForDownloadConfiguration) { | 	for certName, certPath := range certsToTransfer(initForDownloadConfiguration) { | ||||||
| 		diskCertData, err := ioutil.ReadFile(certPath) | 		diskCertData, err := os.ReadFile(certPath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Errorf("error reading certificate from disk: %v", err) | 			t.Errorf("error reading certificate from disk: %v", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package etcd | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -138,7 +137,7 @@ func TestCreateLocalEtcdStaticPodManifestFileWithPatches(t *testing.T) { | |||||||
| 	    patched: "true" | 	    patched: "true" | ||||||
| 	`) | 	`) | ||||||
|  |  | ||||||
| 	err = ioutil.WriteFile(filepath.Join(patchesPath, kubeadmconstants.Etcd+".yaml"), []byte(patchString), 0644) | 	err = os.WriteFile(filepath.Join(patchesPath, kubeadmconstants.Etcd+".yaml"), []byte(patchString), 0644) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("WriteFile returned unexpected error: %v", err) | 		t.Fatalf("WriteFile returned unexpected error: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package kubelet | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
|  |  | ||||||
| @@ -176,7 +175,7 @@ func writeConfigBytesToDisk(b []byte, kubeletDir string) error { | |||||||
| 		return errors.Wrapf(err, "failed to create directory %q", kubeletDir) | 		return errors.Wrapf(err, "failed to create directory %q", kubeletDir) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := ioutil.WriteFile(configFile, b, 0644); err != nil { | 	if err := os.WriteFile(configFile, b, 0644); err != nil { | ||||||
| 		return errors.Wrapf(err, "failed to write kubelet configuration to the file %q", configFile) | 		return errors.Wrapf(err, "failed to write kubelet configuration to the file %q", configFile) | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package kubelet | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"runtime" | 	"runtime" | ||||||
| @@ -153,7 +152,7 @@ func writeKubeletFlagBytesToDisk(b []byte, kubeletDir string) error { | |||||||
| 	if err := os.MkdirAll(kubeletDir, 0700); err != nil { | 	if err := os.MkdirAll(kubeletDir, 0700); err != nil { | ||||||
| 		return errors.Wrapf(err, "failed to create directory %q", kubeletDir) | 		return errors.Wrapf(err, "failed to create directory %q", kubeletDir) | ||||||
| 	} | 	} | ||||||
| 	if err := ioutil.WriteFile(kubeletEnvFilePath, b, 0644); err != nil { | 	if err := os.WriteFile(kubeletEnvFilePath, b, 0644); err != nil { | ||||||
| 		return errors.Wrapf(err, "failed to write kubelet configuration to the file %q", kubeletEnvFilePath) | 		return errors.Wrapf(err, "failed to write kubelet configuration to the file %q", kubeletEnvFilePath) | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package upgrade | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"strings" | 	"strings" | ||||||
| @@ -643,13 +642,13 @@ func TestGetAvailableUpgrades(t *testing.T) { | |||||||
| 				}, | 				}, | ||||||
| 			}) | 			}) | ||||||
|  |  | ||||||
| 			manifestsDir, err := ioutil.TempDir("", "GetAvailableUpgrades-test-manifests") | 			manifestsDir, err := os.MkdirTemp("", "GetAvailableUpgrades-test-manifests") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("Unable to create temporary directory: %v", err) | 				t.Fatalf("Unable to create temporary directory: %v", err) | ||||||
| 			} | 			} | ||||||
| 			defer os.RemoveAll(manifestsDir) | 			defer os.RemoveAll(manifestsDir) | ||||||
|  |  | ||||||
| 			if err = ioutil.WriteFile(constants.GetStaticPodFilepath(constants.Etcd, manifestsDir), []byte(etcdStaticPod), 0644); err != nil { | 			if err = os.WriteFile(constants.GetStaticPodFilepath(constants.Etcd, manifestsDir), []byte(etcdStaticPod), 0644); err != nil { | ||||||
| 				t.Fatalf("Unable to create test static pod manifest: %v", err) | 				t.Fatalf("Unable to create test static pod manifest: %v", err) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package upgrade | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
| @@ -255,12 +254,12 @@ func UpdateKubeletDynamicEnvFileWithURLScheme(dryRun bool) error { | |||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| 	klog.V(2).Infof("Ensuring that %q includes a CRI endpoint URL scheme", filePath) | 	klog.V(2).Infof("Ensuring that %q includes a CRI endpoint URL scheme", filePath) | ||||||
| 	bytes, err := ioutil.ReadFile(filePath) | 	bytes, err := os.ReadFile(filePath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return errors.Wrapf(err, "failed to read kubelet configuration from file %q", filePath) | 		return errors.Wrapf(err, "failed to read kubelet configuration from file %q", filePath) | ||||||
| 	} | 	} | ||||||
| 	updated := updateKubeletDynamicEnvFileWithURLScheme(string(bytes)) | 	updated := updateKubeletDynamicEnvFileWithURLScheme(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 errors.Wrapf(err, "failed to write kubelet configuration to the file %q", filePath) | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"crypto/sha256" | 	"crypto/sha256" | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"math/big" | 	"math/big" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| @@ -154,7 +153,7 @@ type fakeStaticPodPathManager struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| func NewFakeStaticPodPathManager(moveFileFunc func(string, string) error) (StaticPodPathManager, error) { | func NewFakeStaticPodPathManager(moveFileFunc func(string, string) error) (StaticPodPathManager, error) { | ||||||
| 	kubernetesDir, err := ioutil.TempDir("", "kubeadm-pathmanager-") | 	kubernetesDir, err := os.MkdirTemp("", "kubeadm-pathmanager-") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, errors.Wrapf(err, "couldn't create a temporary directory for the upgrade") | 		return nil, errors.Wrapf(err, "couldn't create a temporary directory for the upgrade") | ||||||
| 	} | 	} | ||||||
| @@ -453,12 +452,12 @@ func TestStaticPodControlPlane(t *testing.T) { | |||||||
| 			defer os.RemoveAll(pathMgr.(*fakeStaticPodPathManager).KubernetesDir()) | 			defer os.RemoveAll(pathMgr.(*fakeStaticPodPathManager).KubernetesDir()) | ||||||
| 			tmpKubernetesDir := pathMgr.(*fakeStaticPodPathManager).KubernetesDir() | 			tmpKubernetesDir := pathMgr.(*fakeStaticPodPathManager).KubernetesDir() | ||||||
|  |  | ||||||
| 			tempCertsDir, err := ioutil.TempDir("", "kubeadm-certs") | 			tempCertsDir, err := os.MkdirTemp("", "kubeadm-certs") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("couldn't create temporary certificates directory: %v", err) | 				t.Fatalf("couldn't create temporary certificates directory: %v", err) | ||||||
| 			} | 			} | ||||||
| 			defer os.RemoveAll(tempCertsDir) | 			defer os.RemoveAll(tempCertsDir) | ||||||
| 			tmpEtcdDataDir, err := ioutil.TempDir("", "kubeadm-etcd-data") | 			tmpEtcdDataDir, err := os.MkdirTemp("", "kubeadm-etcd-data") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("couldn't create temporary etcd data directory: %v", err) | 				t.Fatalf("couldn't create temporary etcd data directory: %v", err) | ||||||
| 			} | 			} | ||||||
| @@ -573,7 +572,7 @@ func TestStaticPodControlPlane(t *testing.T) { | |||||||
| func getAPIServerHash(dir string) (string, error) { | func getAPIServerHash(dir string) (string, error) { | ||||||
| 	manifestPath := constants.GetStaticPodFilepath(constants.KubeAPIServer, dir) | 	manifestPath := constants.GetStaticPodFilepath(constants.KubeAPIServer, dir) | ||||||
|  |  | ||||||
| 	fileBytes, err := ioutil.ReadFile(manifestPath) | 	fileBytes, err := os.ReadFile(manifestPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
| @@ -589,7 +588,7 @@ func getConfig(version, certsDir, etcdDataDir string) (*kubeadmapi.InitConfigura | |||||||
| } | } | ||||||
|  |  | ||||||
| func getTempDir(t *testing.T, name string) (string, func()) { | func getTempDir(t *testing.T, name string) (string, func()) { | ||||||
| 	dir, err := ioutil.TempDir(os.TempDir(), name) | 	dir, err := os.MkdirTemp(os.TempDir(), name) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("couldn't make temporary directory: %v", err) | 		t.Fatalf("couldn't make temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -942,7 +941,7 @@ func TestGetPathManagerForUpgrade(t *testing.T) { | |||||||
| 	for _, test := range tests { | 	for _, test := range tests { | ||||||
| 		t.Run(test.name, func(t *testing.T) { | 		t.Run(test.name, func(t *testing.T) { | ||||||
| 			// Use a temporary directory | 			// Use a temporary directory | ||||||
| 			tmpdir, err := ioutil.TempDir("", "TestGetPathManagerForUpgrade") | 			tmpdir, err := os.MkdirTemp("", "TestGetPathManagerForUpgrade") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("unexpected error making temporary directory: %v", err) | 				t.Fatalf("unexpected error making temporary directory: %v", err) | ||||||
| 			} | 			} | ||||||
| @@ -1000,13 +999,13 @@ spec: | |||||||
|   - name: etcd |   - name: etcd | ||||||
|     image: k8s.gcr.io/etcd:` + expectedEtcdVersion |     image: k8s.gcr.io/etcd:` + expectedEtcdVersion | ||||||
|  |  | ||||||
| 	manifestsDir, err := ioutil.TempDir("", "GetEtcdImageTagFromStaticPod-test-manifests") | 	manifestsDir, err := os.MkdirTemp("", "GetEtcdImageTagFromStaticPod-test-manifests") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Unable to create temporary directory: %v", err) | 		t.Fatalf("Unable to create temporary directory: %v", err) | ||||||
| 	} | 	} | ||||||
| 	defer os.RemoveAll(manifestsDir) | 	defer os.RemoveAll(manifestsDir) | ||||||
|  |  | ||||||
| 	if err = ioutil.WriteFile(constants.GetStaticPodFilepath(constants.Etcd, manifestsDir), []byte(etcdStaticPod), 0644); err != nil { | 	if err = os.WriteFile(constants.GetStaticPodFilepath(constants.Etcd, manifestsDir), []byte(etcdStaticPod), 0644); err != nil { | ||||||
| 		t.Fatalf("Unable to create test static pod manifest: %v", err) | 		t.Fatalf("Unable to create test static pod manifest: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,7 +24,6 @@ import ( | |||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" | 	"net/url" | ||||||
| @@ -741,7 +740,7 @@ func (evc ExternalEtcdVersionCheck) Check() (warnings, errorList []error) { | |||||||
| func (evc ExternalEtcdVersionCheck) configRootCAs(config *tls.Config) (*tls.Config, error) { | func (evc ExternalEtcdVersionCheck) configRootCAs(config *tls.Config) (*tls.Config, error) { | ||||||
| 	var CACertPool *x509.CertPool | 	var CACertPool *x509.CertPool | ||||||
| 	if evc.Etcd.External.CAFile != "" { | 	if evc.Etcd.External.CAFile != "" { | ||||||
| 		CACert, err := ioutil.ReadFile(evc.Etcd.External.CAFile) | 		CACert, err := os.ReadFile(evc.Etcd.External.CAFile) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, errors.Wrapf(err, "couldn't load external etcd's server certificate %s", evc.Etcd.External.CAFile) | 			return nil, errors.Wrapf(err, "couldn't load external etcd's server certificate %s", evc.Etcd.External.CAFile) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package preflight | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -335,7 +334,7 @@ func TestFileContentCheck(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestDirAvailableCheck(t *testing.T) { | func TestDirAvailableCheck(t *testing.T) { | ||||||
| 	fileDir, err := ioutil.TempDir("", "dir-avail-check") | 	fileDir, err := os.MkdirTemp("", "dir-avail-check") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("failed creating directory: %v", err) | 		t.Fatalf("failed creating directory: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -455,12 +454,12 @@ func TestRunChecks(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| func TestConfigRootCAs(t *testing.T) { | func TestConfigRootCAs(t *testing.T) { | ||||||
| 	f, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-cafile") | 	f, err := os.CreateTemp(os.TempDir(), "kubeadm-external-etcd-test-cafile") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("failed configRootCAs:\n\texpected: succeed creating temp CA file\n\tactual:%v", err) | 		t.Errorf("failed configRootCAs:\n\texpected: succeed creating temp CA file\n\tactual:%v", err) | ||||||
| 	} | 	} | ||||||
| 	defer os.Remove(f.Name()) | 	defer os.Remove(f.Name()) | ||||||
| 	if err := ioutil.WriteFile(f.Name(), []byte(externalEtcdRootCAFileContent), 0644); err != nil { | 	if err := os.WriteFile(f.Name(), []byte(externalEtcdRootCAFileContent), 0644); err != nil { | ||||||
| 		t.Errorf("failed configRootCAs:\n\texpected: succeed writing contents to temp CA file %s\n\tactual:%v", f.Name(), err) | 		t.Errorf("failed configRootCAs:\n\texpected: succeed writing contents to temp CA file %s\n\tactual:%v", f.Name(), err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -481,7 +480,7 @@ func TestConfigRootCAs(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| func TestConfigCertAndKey(t *testing.T) { | func TestConfigCertAndKey(t *testing.T) { | ||||||
| 	certFile, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-certfile") | 	certFile, err := os.CreateTemp(os.TempDir(), "kubeadm-external-etcd-test-certfile") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf( | 		t.Errorf( | ||||||
| 			"failed configCertAndKey:\n\texpected: succeed creating temp CertFile file\n\tactual:%v", | 			"failed configCertAndKey:\n\texpected: succeed creating temp CertFile file\n\tactual:%v", | ||||||
| @@ -489,7 +488,7 @@ func TestConfigCertAndKey(t *testing.T) { | |||||||
| 		) | 		) | ||||||
| 	} | 	} | ||||||
| 	defer os.Remove(certFile.Name()) | 	defer os.Remove(certFile.Name()) | ||||||
| 	if err := ioutil.WriteFile(certFile.Name(), []byte(externalEtcdCertFileContent), 0644); err != nil { | 	if err := os.WriteFile(certFile.Name(), []byte(externalEtcdCertFileContent), 0644); err != nil { | ||||||
| 		t.Errorf( | 		t.Errorf( | ||||||
| 			"failed configCertAndKey:\n\texpected: succeed writing contents to temp CertFile file %s\n\tactual:%v", | 			"failed configCertAndKey:\n\texpected: succeed writing contents to temp CertFile file %s\n\tactual:%v", | ||||||
| 			certFile.Name(), | 			certFile.Name(), | ||||||
| @@ -497,7 +496,7 @@ func TestConfigCertAndKey(t *testing.T) { | |||||||
| 		) | 		) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	keyFile, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-keyfile") | 	keyFile, err := os.CreateTemp(os.TempDir(), "kubeadm-external-etcd-test-keyfile") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf( | 		t.Errorf( | ||||||
| 			"failed configCertAndKey:\n\texpected: succeed creating temp KeyFile file\n\tactual:%v", | 			"failed configCertAndKey:\n\texpected: succeed creating temp KeyFile file\n\tactual:%v", | ||||||
| @@ -505,7 +504,7 @@ func TestConfigCertAndKey(t *testing.T) { | |||||||
| 		) | 		) | ||||||
| 	} | 	} | ||||||
| 	defer os.Remove(keyFile.Name()) | 	defer os.Remove(keyFile.Name()) | ||||||
| 	if err := ioutil.WriteFile(keyFile.Name(), []byte(externalEtcdKeyFileContent), 0644); err != nil { | 	if err := os.WriteFile(keyFile.Name(), []byte(externalEtcdKeyFileContent), 0644); err != nil { | ||||||
| 		t.Errorf( | 		t.Errorf( | ||||||
| 			"failed configCertAndKey:\n\texpected: succeed writing contents to temp KeyFile file %s\n\tactual:%v", | 			"failed configCertAndKey:\n\texpected: succeed writing contents to temp KeyFile file %s\n\tactual:%v", | ||||||
| 			keyFile.Name(), | 			keyFile.Name(), | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package config | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -199,7 +198,7 @@ G+2/lm8TaVjoU7Fi5Ka5G5HY2GLaR7P+IxYcrMHCl62Y7Rqcrnc= | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestGetNodeNameFromKubeletConfig(t *testing.T) { | func TestGetNodeNameFromKubeletConfig(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -246,7 +245,7 @@ func TestGetNodeNameFromKubeletConfig(t *testing.T) { | |||||||
| 		t.Run(rt.name, func(t2 *testing.T) { | 		t.Run(rt.name, func(t2 *testing.T) { | ||||||
| 			if len(rt.pemContent) > 0 { | 			if len(rt.pemContent) > 0 { | ||||||
| 				pemPath := filepath.Join(tmpdir, "kubelet.pem") | 				pemPath := filepath.Join(tmpdir, "kubelet.pem") | ||||||
| 				err := ioutil.WriteFile(pemPath, rt.pemContent, 0644) | 				err := os.WriteFile(pemPath, rt.pemContent, 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Errorf("Couldn't create pem file: %v", err) | 					t.Errorf("Couldn't create pem file: %v", err) | ||||||
| 					return | 					return | ||||||
| @@ -255,7 +254,7 @@ func TestGetNodeNameFromKubeletConfig(t *testing.T) { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			kubeconfigPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | 			kubeconfigPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | ||||||
| 			err := ioutil.WriteFile(kubeconfigPath, rt.kubeconfigContent, 0644) | 			err := os.WriteFile(kubeconfigPath, rt.kubeconfigContent, 0644) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Errorf("Couldn't create kubeconfig: %v", err) | 				t.Errorf("Couldn't create kubeconfig: %v", err) | ||||||
| 				return | 				return | ||||||
| @@ -278,7 +277,7 @@ func TestGetNodeNameFromKubeletConfig(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestGetNodeRegistration(t *testing.T) { | func TestGetNodeRegistration(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -320,7 +319,7 @@ func TestGetNodeRegistration(t *testing.T) { | |||||||
| 		t.Run(rt.name, func(t2 *testing.T) { | 		t.Run(rt.name, func(t2 *testing.T) { | ||||||
| 			cfgPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | 			cfgPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | ||||||
| 			if len(rt.fileContents) > 0 { | 			if len(rt.fileContents) > 0 { | ||||||
| 				err := ioutil.WriteFile(cfgPath, rt.fileContents, 0644) | 				err := os.WriteFile(cfgPath, rt.fileContents, 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Errorf("Couldn't create file") | 					t.Errorf("Couldn't create file") | ||||||
| 					return | 					return | ||||||
| @@ -491,7 +490,7 @@ func TestGetAPIEndpointWithBackoff(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestGetInitConfigurationFromCluster(t *testing.T) { | func TestGetInitConfigurationFromCluster(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -680,7 +679,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) { | |||||||
| 		t.Run(rt.name, func(t *testing.T) { | 		t.Run(rt.name, func(t *testing.T) { | ||||||
| 			cfgPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | 			cfgPath := filepath.Join(tmpdir, kubeadmconstants.KubeletKubeConfigFileName) | ||||||
| 			if len(rt.fileContents) > 0 { | 			if len(rt.fileContents) > 0 { | ||||||
| 				err := ioutil.WriteFile(cfgPath, rt.fileContents, 0644) | 				err := os.WriteFile(cfgPath, rt.fileContents, 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Errorf("Couldn't create file") | 					t.Errorf("Couldn't create file") | ||||||
| 					return | 					return | ||||||
|   | |||||||
| @@ -18,8 +18,8 @@ package config | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
|  | 	"os" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| @@ -254,7 +254,7 @@ func DefaultedInitConfiguration(versionedInitCfg *kubeadmapiv1.InitConfiguration | |||||||
| func LoadInitConfigurationFromFile(cfgPath string) (*kubeadmapi.InitConfiguration, error) { | func LoadInitConfigurationFromFile(cfgPath string) (*kubeadmapi.InitConfiguration, error) { | ||||||
| 	klog.V(1).Infof("loading configuration from %q", cfgPath) | 	klog.V(1).Infof("loading configuration from %q", cfgPath) | ||||||
|  |  | ||||||
| 	b, err := ioutil.ReadFile(cfgPath) | 	b, err := os.ReadFile(cfgPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, errors.Wrapf(err, "unable to read config from %q ", cfgPath) | 		return nil, errors.Wrapf(err, "unable to read config from %q ", cfgPath) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package config | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -33,7 +32,7 @@ import ( | |||||||
|  |  | ||||||
| func TestLoadInitConfigurationFromFile(t *testing.T) { | func TestLoadInitConfigurationFromFile(t *testing.T) { | ||||||
| 	// Create temp folder for the test case | 	// Create temp folder for the test case | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir: %v", err) | 		t.Fatalf("Couldn't create tmpdir: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -84,7 +83,7 @@ func TestLoadInitConfigurationFromFile(t *testing.T) { | |||||||
| 	for _, rt := range tests { | 	for _, rt := range tests { | ||||||
| 		t.Run(rt.name, func(t2 *testing.T) { | 		t.Run(rt.name, func(t2 *testing.T) { | ||||||
| 			cfgPath := filepath.Join(tmpdir, rt.name) | 			cfgPath := filepath.Join(tmpdir, rt.name) | ||||||
| 			err := ioutil.WriteFile(cfgPath, rt.fileContents, 0644) | 			err := os.WriteFile(cfgPath, rt.fileContents, 0644) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Errorf("Couldn't create file: %v", err) | 				t.Errorf("Couldn't create file: %v", err) | ||||||
| 				return | 				return | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package config | package config | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"os" | ||||||
|  |  | ||||||
| 	"github.com/pkg/errors" | 	"github.com/pkg/errors" | ||||||
|  |  | ||||||
| @@ -75,7 +75,7 @@ func LoadOrDefaultJoinConfiguration(cfgPath string, defaultversionedcfg *kubeadm | |||||||
| func LoadJoinConfigurationFromFile(cfgPath string) (*kubeadmapi.JoinConfiguration, error) { | func LoadJoinConfigurationFromFile(cfgPath string) (*kubeadmapi.JoinConfiguration, error) { | ||||||
| 	klog.V(1).Infof("loading configuration from %q", cfgPath) | 	klog.V(1).Infof("loading configuration from %q", cfgPath) | ||||||
|  |  | ||||||
| 	b, err := ioutil.ReadFile(cfgPath) | 	b, err := os.ReadFile(cfgPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, errors.Wrapf(err, "unable to read config from %q ", cfgPath) | 		return nil, errors.Wrapf(err, "unable to read config from %q ", cfgPath) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ package config | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -30,7 +29,7 @@ import ( | |||||||
|  |  | ||||||
| func TestLoadJoinConfigurationFromFile(t *testing.T) { | func TestLoadJoinConfigurationFromFile(t *testing.T) { | ||||||
| 	// Create temp folder for the test case | 	// Create temp folder for the test case | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir: %v", err) | 		t.Fatalf("Couldn't create tmpdir: %v", err) | ||||||
| 	} | 	} | ||||||
| @@ -97,7 +96,7 @@ func TestLoadJoinConfigurationFromFile(t *testing.T) { | |||||||
| 	for _, rt := range tests { | 	for _, rt := range tests { | ||||||
| 		t.Run(rt.name, func(t2 *testing.T) { | 		t.Run(rt.name, func(t2 *testing.T) { | ||||||
| 			cfgPath := filepath.Join(tmpdir, rt.name) | 			cfgPath := filepath.Join(tmpdir, rt.name) | ||||||
| 			err := ioutil.WriteFile(cfgPath, []byte(rt.fileContents), 0644) | 			err := os.WriteFile(cfgPath, []byte(rt.fileContents), 0644) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Errorf("Couldn't create file: %v", err) | 				t.Errorf("Couldn't create file: %v", err) | ||||||
| 				return | 				return | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package strict | package strict | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| @@ -143,7 +143,7 @@ func TestVerifyUnmarshalStrict(t *testing.T) { | |||||||
|  |  | ||||||
| 	for _, test := range testFiles { | 	for _, test := range testFiles { | ||||||
| 		t.Run(test.fileName, func(t *testing.T) { | 		t.Run(test.fileName, func(t *testing.T) { | ||||||
| 			bytes, err := ioutil.ReadFile(filepath.Join(pathTestData, test.fileName)) | 			bytes, err := os.ReadFile(filepath.Join(pathTestData, test.fileName)) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("couldn't read test data: %v", err) | 				t.Fatalf("couldn't read test data: %v", err) | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package dryrun | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -61,7 +61,7 @@ func PrintDryRunFiles(files []FileToPrint, w io.Writer) error { | |||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		fileBytes, err := ioutil.ReadFile(file.RealPath) | 		fileBytes, err := os.ReadFile(file.RealPath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			errs = append(errs, err) | 			errs = append(errs, err) | ||||||
| 			continue | 			continue | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ package kubeconfig | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"os" | ||||||
|  |  | ||||||
| 	"github.com/pkg/errors" | 	"github.com/pkg/errors" | ||||||
|  |  | ||||||
| @@ -151,7 +151,7 @@ func EnsureAuthenticationInfoAreEmbedded(config *clientcmdapi.Config) error { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if len(authInfo.ClientCertificateData) == 0 && len(authInfo.ClientCertificate) != 0 { | 	if len(authInfo.ClientCertificateData) == 0 && len(authInfo.ClientCertificate) != 0 { | ||||||
| 		clientCert, err := ioutil.ReadFile(authInfo.ClientCertificate) | 		clientCert, err := os.ReadFile(authInfo.ClientCertificate) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return errors.Wrap(err, "error while reading client cert file defined in kubeconfig") | 			return errors.Wrap(err, "error while reading client cert file defined in kubeconfig") | ||||||
| 		} | 		} | ||||||
| @@ -159,7 +159,7 @@ func EnsureAuthenticationInfoAreEmbedded(config *clientcmdapi.Config) error { | |||||||
| 		authInfo.ClientCertificate = "" | 		authInfo.ClientCertificate = "" | ||||||
| 	} | 	} | ||||||
| 	if len(authInfo.ClientKeyData) == 0 && len(authInfo.ClientKey) != 0 { | 	if len(authInfo.ClientKeyData) == 0 && len(authInfo.ClientKey) != 0 { | ||||||
| 		clientKey, err := ioutil.ReadFile(authInfo.ClientKey) | 		clientKey, err := os.ReadFile(authInfo.ClientKey) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return errors.Wrap(err, "error while reading client key file defined in kubeconfig") | 			return errors.Wrap(err, "error while reading client key file defined in kubeconfig") | ||||||
| 		} | 		} | ||||||
| @@ -178,7 +178,7 @@ func EnsureCertificateAuthorityIsEmbedded(cluster *clientcmdapi.Cluster) error { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if len(cluster.CertificateAuthorityData) == 0 && len(cluster.CertificateAuthority) != 0 { | 	if len(cluster.CertificateAuthorityData) == 0 && len(cluster.CertificateAuthority) != 0 { | ||||||
| 		ca, err := ioutil.ReadFile(cluster.CertificateAuthority) | 		ca, err := os.ReadFile(cluster.CertificateAuthority) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return errors.Wrap(err, "error while reading certificate authority file defined in kubeconfig") | 			return errors.Wrap(err, "error while reading certificate authority file defined in kubeconfig") | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package kubeconfig | |||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| @@ -143,7 +142,7 @@ func TestCreateWithToken(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWriteKubeconfigToDisk(t *testing.T) { | func TestWriteKubeconfigToDisk(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -177,7 +176,7 @@ func TestWriteKubeconfigToDisk(t *testing.T) { | |||||||
| 					err, | 					err, | ||||||
| 				) | 				) | ||||||
| 			} | 			} | ||||||
| 			newFile, _ := ioutil.ReadFile(configPath) | 			newFile, _ := os.ReadFile(configPath) | ||||||
| 			if !bytes.Equal(newFile, rt.file) { | 			if !bytes.Equal(newFile, rt.file) { | ||||||
| 				t.Errorf( | 				t.Errorf( | ||||||
| 					"failed WriteToDisk config write:\n\texpected: %s\n\t  actual: %s", | 					"failed WriteToDisk config write:\n\texpected: %s\n\t  actual: %s", | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| @@ -104,7 +103,7 @@ func GetPatchManagerForPath(path string, knownTargets []string, output io.Writer | |||||||
| 	pathLock.RUnlock() | 	pathLock.RUnlock() | ||||||
|  |  | ||||||
| 	if output == nil { | 	if output == nil { | ||||||
| 		output = ioutil.Discard | 		output = io.Discard | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	fmt.Fprintf(output, "[patches] Reading patches from path %q\n", path) | 	fmt.Fprintf(output, "[patches] Reading patches from path %q\n", path) | ||||||
| @@ -316,7 +315,7 @@ func getPatchSetsFromPath(targetPath string, knownTargets []string, output io.Wr | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Read the patch file. | 		// Read the patch file. | ||||||
| 		data, err := ioutil.ReadFile(path) | 		data, err := os.ReadFile(path) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return errors.Wrapf(err, "could not read the file %q", path) | 			return errors.Wrapf(err, "could not read the file %q", path) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ package patches | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -173,7 +173,7 @@ func TestGetPatchSetsForPathMustBeDirectory(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| 	defer os.Remove(tempFile.Name()) | 	defer os.Remove(tempFile.Name()) | ||||||
|  |  | ||||||
| 	_, _, _, err = getPatchSetsFromPath(tempFile.Name(), testKnownTargets, ioutil.Discard) | 	_, _, _, err = getPatchSetsFromPath(tempFile.Name(), testKnownTargets, io.Discard) | ||||||
| 	var pathErr *os.PathError | 	var pathErr *os.PathError | ||||||
| 	if !errors.As(err, &pathErr) { | 	if !errors.As(err, &pathErr) { | ||||||
| 		t.Fatalf("expected os.PathError for non-directory path %q, but got %v", tempFile.Name(), err) | 		t.Fatalf("expected os.PathError for non-directory path %q, but got %v", tempFile.Name(), err) | ||||||
| @@ -233,7 +233,7 @@ func TestGetPatchSetsForPath(t *testing.T) { | |||||||
|  |  | ||||||
| 	for _, tc := range tests { | 	for _, tc := range tests { | ||||||
| 		t.Run(tc.name, func(t *testing.T) { | 		t.Run(tc.name, func(t *testing.T) { | ||||||
| 			tempDir, err := ioutil.TempDir("", testDirPattern) | 			tempDir, err := os.MkdirTemp("", testDirPattern) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatal(err) | 				t.Fatal(err) | ||||||
| 			} | 			} | ||||||
| @@ -241,13 +241,13 @@ func TestGetPatchSetsForPath(t *testing.T) { | |||||||
|  |  | ||||||
| 			for _, file := range tc.filesToWrite { | 			for _, file := range tc.filesToWrite { | ||||||
| 				filePath := filepath.Join(tempDir, file) | 				filePath := filepath.Join(tempDir, file) | ||||||
| 				err := ioutil.WriteFile(filePath, []byte(tc.patchData), 0644) | 				err := os.WriteFile(filePath, []byte(tc.patchData), 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("could not write temporary file %q", filePath) | 					t.Fatalf("could not write temporary file %q", filePath) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			patchSets, patchFiles, ignoredFiles, err := getPatchSetsFromPath(tempDir, testKnownTargets, ioutil.Discard) | 			patchSets, patchFiles, ignoredFiles, err := getPatchSetsFromPath(tempDir, testKnownTargets, io.Discard) | ||||||
| 			if (err != nil) != tc.expectedError { | 			if (err != nil) != tc.expectedError { | ||||||
| 				t.Fatalf("expected error: %v, got: %v, error: %v", tc.expectedError, err != nil, err) | 				t.Fatalf("expected error: %v, got: %v, error: %v", tc.expectedError, err != nil, err) | ||||||
| 			} | 			} | ||||||
| @@ -361,7 +361,7 @@ func TestGetPatchManagerForPath(t *testing.T) { | |||||||
|  |  | ||||||
| 	for _, tc := range tests { | 	for _, tc := range tests { | ||||||
| 		t.Run(tc.name, func(t *testing.T) { | 		t.Run(tc.name, func(t *testing.T) { | ||||||
| 			tempDir, err := ioutil.TempDir("", testDirPattern) | 			tempDir, err := os.MkdirTemp("", testDirPattern) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatal(err) | 				t.Fatal(err) | ||||||
| 			} | 			} | ||||||
| @@ -369,7 +369,7 @@ func TestGetPatchManagerForPath(t *testing.T) { | |||||||
|  |  | ||||||
| 			for _, file := range tc.files { | 			for _, file := range tc.files { | ||||||
| 				filePath := filepath.Join(tempDir, file.name) | 				filePath := filepath.Join(tempDir, file.name) | ||||||
| 				err := ioutil.WriteFile(filePath, []byte(file.data), 0644) | 				err := os.WriteFile(filePath, []byte(file.data), 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("could not write temporary file %q", filePath) | 					t.Fatalf("could not write temporary file %q", filePath) | ||||||
| 				} | 				} | ||||||
| @@ -396,7 +396,7 @@ func TestGetPatchManagerForPath(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestGetPatchManagerForPathCache(t *testing.T) { | func TestGetPatchManagerForPathCache(t *testing.T) { | ||||||
| 	tempDir, err := ioutil.TempDir("", testDirPattern) | 	tempDir, err := os.MkdirTemp("", testDirPattern) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -27,7 +27,6 @@ import ( | |||||||
| 	"crypto/x509/pkix" | 	"crypto/x509/pkix" | ||||||
| 	"encoding/pem" | 	"encoding/pem" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"math" | 	"math" | ||||||
| 	"math/big" | 	"math/big" | ||||||
| 	"net" | 	"net" | ||||||
| @@ -217,7 +216,7 @@ func WriteCSR(csrDir, name string, csr *x509.CertificateRequest) error { | |||||||
| 		return errors.Wrapf(err, "failed to make directory %s", filepath.Dir(csrPath)) | 		return errors.Wrapf(err, "failed to make directory %s", filepath.Dir(csrPath)) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := ioutil.WriteFile(csrPath, EncodeCSRPEM(csr), os.FileMode(0600)); err != nil { | 	if err := os.WriteFile(csrPath, EncodeCSRPEM(csr), os.FileMode(0600)); err != nil { | ||||||
| 		return errors.Wrapf(err, "unable to write CSR to file %s", csrPath) | 		return errors.Wrapf(err, "unable to write CSR to file %s", csrPath) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -550,7 +549,7 @@ func parseCSRPEM(pemCSR []byte) (*x509.CertificateRequest, error) { | |||||||
| // CertificateRequestFromFile returns the CertificateRequest from a given PEM-encoded file. | // CertificateRequestFromFile returns the CertificateRequest from a given PEM-encoded file. | ||||||
| // Returns an error if the file could not be read or if the CSR could not be parsed. | // Returns an error if the file could not be read or if the CSR could not be parsed. | ||||||
| func CertificateRequestFromFile(file string) (*x509.CertificateRequest, error) { | func CertificateRequestFromFile(file string) (*x509.CertificateRequest, error) { | ||||||
| 	pemBlock, err := ioutil.ReadFile(file) | 	pemBlock, err := os.ReadFile(file) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, errors.Wrap(err, "failed to read file") | 		return nil, errors.Wrap(err, "failed to read file") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ import ( | |||||||
| 	"crypto/rand" | 	"crypto/rand" | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -176,7 +175,7 @@ func TestHasServerAuth(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWriteCertAndKey(t *testing.T) { | func TestWriteCertAndKey(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -193,7 +192,7 @@ func TestWriteCertAndKey(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWriteCert(t *testing.T) { | func TestWriteCert(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -210,7 +209,7 @@ func TestWriteCert(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWriteCertBundle(t *testing.T) { | func TestWriteCertBundle(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -225,7 +224,7 @@ func TestWriteCertBundle(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWriteKey(t *testing.T) { | func TestWriteKey(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -241,7 +240,7 @@ func TestWriteKey(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestWritePublicKey(t *testing.T) { | func TestWritePublicKey(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -257,7 +256,7 @@ func TestWritePublicKey(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestCertOrKeyExist(t *testing.T) { | func TestCertOrKeyExist(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -306,7 +305,7 @@ func TestCertOrKeyExist(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestTryLoadCertAndKeyFromDisk(t *testing.T) { | func TestTryLoadCertAndKeyFromDisk(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -354,7 +353,7 @@ func TestTryLoadCertAndKeyFromDisk(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestTryLoadCertFromDisk(t *testing.T) { | func TestTryLoadCertFromDisk(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -402,7 +401,7 @@ func TestTryLoadCertFromDisk(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestTryLoadCertChainFromDisk(t *testing.T) { | func TestTryLoadCertChainFromDisk(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -502,7 +501,7 @@ func TestTryLoadKeyFromDisk(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| 	for _, rt := range tests { | 	for _, rt := range tests { | ||||||
| 		t.Run(rt.desc, func(t *testing.T) { | 		t.Run(rt.desc, func(t *testing.T) { | ||||||
| 			tmpdir, err := ioutil.TempDir("", "") | 			tmpdir, err := os.MkdirTemp("", "") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatalf("Couldn't create tmpdir") | 				t.Fatalf("Couldn't create tmpdir") | ||||||
| 			} | 			} | ||||||
| @@ -849,7 +848,7 @@ func TestRemoveDuplicateAltNames(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestVerifyCertChain(t *testing.T) { | func TestVerifyCertChain(t *testing.T) { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package runtime | package runtime | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"os" | 	"os" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -314,7 +313,7 @@ func TestIsExistingSocket(t *testing.T) { | |||||||
| 		{ | 		{ | ||||||
| 			name: "Valid domain socket is detected as such", | 			name: "Valid domain socket is detected as such", | ||||||
| 			proc: func(t *testing.T) { | 			proc: func(t *testing.T) { | ||||||
| 				tmpFile, err := ioutil.TempFile("", tempPrefix) | 				tmpFile, err := os.CreateTemp("", tempPrefix) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("unexpected error by TempFile: %v", err) | 					t.Fatalf("unexpected error by TempFile: %v", err) | ||||||
| 				} | 				} | ||||||
| @@ -336,7 +335,7 @@ func TestIsExistingSocket(t *testing.T) { | |||||||
| 		{ | 		{ | ||||||
| 			name: "Regular file is not a domain socket", | 			name: "Regular file is not a domain socket", | ||||||
| 			proc: func(t *testing.T) { | 			proc: func(t *testing.T) { | ||||||
| 				tmpFile, err := ioutil.TempFile("", tempPrefix) | 				tmpFile, err := os.CreateTemp("", tempPrefix) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("unexpected error by TempFile: %v", err) | 					t.Fatalf("unexpected error by TempFile: %v", err) | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ import ( | |||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"math" | 	"math" | ||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -219,7 +218,7 @@ func WriteStaticPodToDisk(componentName, manifestDir string, pod v1.Pod) error { | |||||||
|  |  | ||||||
| 	filename := kubeadmconstants.GetStaticPodFilepath(componentName, manifestDir) | 	filename := kubeadmconstants.GetStaticPodFilepath(componentName, manifestDir) | ||||||
|  |  | ||||||
| 	if err := ioutil.WriteFile(filename, serialized, 0600); err != nil { | 	if err := os.WriteFile(filename, serialized, 0600); err != nil { | ||||||
| 		return errors.Wrapf(err, "failed to write static pod manifest file for %q (%q)", componentName, filename) | 		return errors.Wrapf(err, "failed to write static pod manifest file for %q (%q)", componentName, filename) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -228,7 +227,7 @@ func WriteStaticPodToDisk(componentName, manifestDir string, pod v1.Pod) error { | |||||||
|  |  | ||||||
| // ReadStaticPodFromDisk reads a static pod file from disk | // ReadStaticPodFromDisk reads a static pod file from disk | ||||||
| func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) { | func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) { | ||||||
| 	buf, err := ioutil.ReadFile(manifestPath) | 	buf, err := os.ReadFile(manifestPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &v1.Pod{}, errors.Wrapf(err, "failed to read manifest for %q", manifestPath) | 		return &v1.Pod{}, errors.Wrapf(err, "failed to read manifest for %q", manifestPath) | ||||||
| 	} | 	} | ||||||
| @@ -362,11 +361,11 @@ func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.UR | |||||||
|  |  | ||||||
| // ManifestFilesAreEqual compares 2 files. It returns true if their contents are equal, false otherwise | // ManifestFilesAreEqual compares 2 files. It returns true if their contents are equal, false otherwise | ||||||
| func ManifestFilesAreEqual(path1, path2 string) (bool, error) { | func ManifestFilesAreEqual(path1, path2 string) (bool, error) { | ||||||
| 	content1, err := ioutil.ReadFile(path1) | 	content1, err := os.ReadFile(path1) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return false, err | 		return false, err | ||||||
| 	} | 	} | ||||||
| 	content2, err := ioutil.ReadFile(path2) | 	content2, err := os.ReadFile(path2) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return false, err | 		return false, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package staticpod | package staticpod | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| @@ -664,7 +664,7 @@ func TestReadStaticPodFromDisk(t *testing.T) { | |||||||
|  |  | ||||||
| 			manifestPath := filepath.Join(tmpdir, "pod.yaml") | 			manifestPath := filepath.Join(tmpdir, "pod.yaml") | ||||||
| 			if rt.writeManifest { | 			if rt.writeManifest { | ||||||
| 				err := ioutil.WriteFile(manifestPath, []byte(rt.podYaml), 0644) | 				err := os.WriteFile(manifestPath, []byte(rt.podYaml), 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("Failed to write pod manifest\n%s\n\tfatal error: %v", rt.description, err) | 					t.Fatalf("Failed to write pod manifest\n%s\n\tfatal error: %v", rt.description, err) | ||||||
| 				} | 				} | ||||||
| @@ -726,7 +726,7 @@ func TestManifestFilesAreEqual(t *testing.T) { | |||||||
| 			for i := 0; i < 2; i++ { | 			for i := 0; i < 2; i++ { | ||||||
| 				if rt.podYamls[i] != "" { | 				if rt.podYamls[i] != "" { | ||||||
| 					manifestPath := filepath.Join(tmpdir, strconv.Itoa(i)+".yaml") | 					manifestPath := filepath.Join(tmpdir, strconv.Itoa(i)+".yaml") | ||||||
| 					err := ioutil.WriteFile(manifestPath, []byte(rt.podYamls[i]), 0644) | 					err := os.WriteFile(manifestPath, []byte(rt.podYamls[i]), 0644) | ||||||
| 					if err != nil { | 					if err != nil { | ||||||
| 						t.Fatalf("Failed to write manifest file\n%s\n\tfatal error: %v", rt.description, err) | 						t.Fatalf("Failed to write manifest file\n%s\n\tfatal error: %v", rt.description, err) | ||||||
| 					} | 					} | ||||||
| @@ -808,7 +808,7 @@ func TestPatchStaticPod(t *testing.T) { | |||||||
|  |  | ||||||
| 	for _, tc := range tests { | 	for _, tc := range tests { | ||||||
| 		t.Run(tc.name, func(t *testing.T) { | 		t.Run(tc.name, func(t *testing.T) { | ||||||
| 			tempDir, err := ioutil.TempDir("", "patch-files") | 			tempDir, err := os.MkdirTemp("", "patch-files") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatal(err) | 				t.Fatal(err) | ||||||
| 			} | 			} | ||||||
| @@ -816,13 +816,13 @@ func TestPatchStaticPod(t *testing.T) { | |||||||
|  |  | ||||||
| 			for _, file := range tc.files { | 			for _, file := range tc.files { | ||||||
| 				filePath := filepath.Join(tempDir, file.name) | 				filePath := filepath.Join(tempDir, file.name) | ||||||
| 				err := ioutil.WriteFile(filePath, []byte(file.data), 0644) | 				err := os.WriteFile(filePath, []byte(file.data), 0644) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Fatalf("could not write temporary file %q", filePath) | 					t.Fatalf("could not write temporary file %q", filePath) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			pod, err := PatchStaticPod(tc.pod, tempDir, ioutil.Discard) | 			pod, err := PatchStaticPod(tc.pod, tempDir, io.Discard) | ||||||
| 			if (err != nil) != tc.expectedError { | 			if (err != nil) != tc.expectedError { | ||||||
| 				t.Fatalf("expected error: %v, got: %v, error: %v", tc.expectedError, (err != nil), err) | 				t.Fatalf("expected error: %v, got: %v, error: %v", tc.expectedError, (err != nil), err) | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ limitations under the License. | |||||||
| package users | package users | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -572,11 +571,11 @@ func TestRemoveUsersAndGroups(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func writeTempFile(t *testing.T, contents string) (string, func()) { | func writeTempFile(t *testing.T, contents string) (string, func()) { | ||||||
| 	file, err := ioutil.TempFile("", "") | 	file, err := os.CreateTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("could not create file: %v", err) | 		t.Fatalf("could not create file: %v", err) | ||||||
| 	} | 	} | ||||||
| 	if err := ioutil.WriteFile(file.Name(), []byte(contents), os.ModePerm); err != nil { | 	if err := os.WriteFile(file.Name(), []byte(contents), os.ModePerm); err != nil { | ||||||
| 		t.Fatalf("could not write file: %v", err) | 		t.Fatalf("could not write file: %v", err) | ||||||
| 	} | 	} | ||||||
| 	close := func() { | 	close := func() { | ||||||
| @@ -586,7 +585,7 @@ func writeTempFile(t *testing.T, contents string) (string, func()) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func readTempFile(t *testing.T, path string) string { | func readTempFile(t *testing.T, path string) string { | ||||||
| 	b, err := ioutil.ReadFile(path) | 	b, err := os.ReadFile(path) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("could not read file: %v", err) | 		t.Fatalf("could not read file: %v", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ package util | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| 	"strings" | 	"strings" | ||||||
| @@ -190,7 +190,7 @@ func fetchFromURL(url string, timeout time.Duration) (string, error) { | |||||||
| 		return "", errors.Errorf("unable to get URL %q: %s", url, err.Error()) | 		return "", errors.Errorf("unable to get URL %q: %s", url, err.Error()) | ||||||
| 	} | 	} | ||||||
| 	defer resp.Body.Close() | 	defer resp.Body.Close() | ||||||
| 	body, err := ioutil.ReadAll(resp.Body) | 	body, err := io.ReadAll(resp.Body) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", errors.Errorf("unable to read content of URL %q: %s", url, err.Error()) | 		return "", errors.Errorf("unable to read content of URL %q: %s", url, err.Error()) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ limitations under the License. | |||||||
| package test | package test | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
| @@ -32,7 +31,7 @@ import ( | |||||||
| // SetupTempDir is a utility function for kubeadm testing, that creates a temporary directory | // SetupTempDir is a utility function for kubeadm testing, that creates a temporary directory | ||||||
| // NB. it is up to the caller to cleanup the folder at the end of the test with defer os.RemoveAll(tmpdir) | // NB. it is up to the caller to cleanup the folder at the end of the test with defer os.RemoveAll(tmpdir) | ||||||
| func SetupTempDir(t *testing.T) string { | func SetupTempDir(t *testing.T) string { | ||||||
| 	tmpdir, err := ioutil.TempDir("", "") | 	tmpdir, err := os.MkdirTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't create tmpdir") | 		t.Fatalf("Couldn't create tmpdir") | ||||||
| 	} | 	} | ||||||
| @@ -68,7 +67,7 @@ func SetupPkiDirWithCertificateAuthority(t *testing.T, tmpdir string) string { | |||||||
| // AssertFilesCount is a utility function for kubeadm testing that asserts if the given folder contains | // AssertFilesCount is a utility function for kubeadm testing that asserts if the given folder contains | ||||||
| // count files. | // count files. | ||||||
| func AssertFilesCount(t *testing.T, dirName string, count int) { | func AssertFilesCount(t *testing.T, dirName string, count int) { | ||||||
| 	files, err := ioutil.ReadDir(dirName) | 	files, err := os.ReadDir(dirName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Couldn't read files from tmpdir: %s", err) | 		t.Fatalf("Couldn't read files from tmpdir: %s", err) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ import ( | |||||||
| 	"crypto/x509/pkix" | 	"crypto/x509/pkix" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"encoding/pem" | 	"encoding/pem" | ||||||
| 	"io/ioutil" | 	"io" | ||||||
| 	"math/big" | 	"math/big" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/http/httptest" | 	"net/http/httptest" | ||||||
| @@ -48,7 +48,7 @@ import ( | |||||||
| // manager that will use the bootstrap client until we get a valid cert, then use our | // manager that will use the bootstrap client until we get a valid cert, then use our | ||||||
| // provided identity on subsequent requests. | // provided identity on subsequent requests. | ||||||
| func Test_buildClientCertificateManager(t *testing.T) { | func Test_buildClientCertificateManager(t *testing.T) { | ||||||
| 	testDir, err := ioutil.TempDir("", "kubeletcert") | 	testDir, err := os.MkdirTemp("", "kubeletcert") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| @@ -134,7 +134,7 @@ func Test_buildClientCertificateManager(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func Test_buildClientCertificateManager_populateCertDir(t *testing.T) { | func Test_buildClientCertificateManager_populateCertDir(t *testing.T) { | ||||||
| 	testDir, err := ioutil.TempDir("", "kubeletcert") | 	testDir, err := os.MkdirTemp("", "kubeletcert") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| @@ -215,7 +215,7 @@ func getCSR(req *http.Request) (*certapi.CertificateSigningRequest, error) { | |||||||
| 	if req.Body == nil { | 	if req.Body == nil { | ||||||
| 		return nil, nil | 		return nil, nil | ||||||
| 	} | 	} | ||||||
| 	body, err := ioutil.ReadAll(req.Body) | 	body, err := io.ReadAll(req.Body) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ package main | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| @@ -81,7 +80,7 @@ func newWalkFunc(invalidLink *bool, client *http.Client) filepath.WalkFunc { | |||||||
| 			return nil | 			return nil | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		fileBytes, err := ioutil.ReadFile(filePath) | 		fileBytes, err := os.ReadFile(filePath) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -27,7 +27,6 @@ import ( | |||||||
| 	"go/format" | 	"go/format" | ||||||
| 	"go/parser" | 	"go/parser" | ||||||
| 	"go/token" | 	"go/token" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"log" | 	"log" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| @@ -129,7 +128,7 @@ func (a *analyzer) collect(dir string) { | |||||||
| 						panic(fmt.Sprintf("Error stat'ing file: %s\n%s\n", pathToFile, err.Error())) | 						panic(fmt.Sprintf("Error stat'ing file: %s\n%s\n", pathToFile, err.Error())) | ||||||
| 					} | 					} | ||||||
|  |  | ||||||
| 					err = ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode()) | 					err = os.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode()) | ||||||
| 					if err != nil { | 					if err != nil { | ||||||
| 						panic(fmt.Sprintf("Error writing file: %s\n%s\n", pathToFile, err.Error())) | 						panic(fmt.Sprintf("Error writing file: %s\n%s\n", pathToFile, err.Error())) | ||||||
| 					} | 					} | ||||||
| @@ -235,7 +234,7 @@ func main() { | |||||||
| 	sort.Strings(c.dirs) | 	sort.Strings(c.dirs) | ||||||
|  |  | ||||||
| 	if len(*importAliases) > 0 { | 	if len(*importAliases) > 0 { | ||||||
| 		bytes, err := ioutil.ReadFile(*importAliases) | 		bytes, err := os.ReadFile(*importAliases) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatalf("Error reading import aliases: %v", err) | 			log.Fatalf("Error reading import aliases: %v", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
| 	"gopkg.in/yaml.v3" | 	"gopkg.in/yaml.v3" | ||||||
| @@ -31,7 +30,7 @@ func main() { | |||||||
|  |  | ||||||
| 	if flag.NArg() > 0 { | 	if flag.NArg() > 0 { | ||||||
| 		for _, path := range flag.Args() { | 		for _, path := range flag.Args() { | ||||||
| 			sourceYaml, err := ioutil.ReadFile(path) | 			sourceYaml, err := os.ReadFile(path) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				panic(err) | 				panic(err) | ||||||
| 			} | 			} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ahrtr
					ahrtr