Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <[email protected]>
  • Loading branch information
testwill authored and alexellis committed Sep 14, 2023
1 parent 1d2e443 commit ca80ac6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net"
"os"
Expand Down Expand Up @@ -428,7 +427,7 @@ kubectl get node -o wide
pkg.SupportMessageShort)
}

if err := ioutil.WriteFile(absPath, []byte(data), 0600); err != nil {
if err := os.WriteFile(absPath, []byte(data), 0600); err != nil {
return err
}

Expand All @@ -437,7 +436,7 @@ kubectl get node -o wide

func mergeConfigs(localKubeconfigPath, context string, k3sconfig []byte) ([]byte, error) {
// Create a temporary kubeconfig to store the config of the newly create k3s cluster
file, err := ioutil.TempFile(os.TempDir(), "k3s-temp-*")
file, err := os.CreateTemp(os.TempDir(), "k3s-temp-*")
if err != nil {
return nil, fmt.Errorf("could not generate a temporary file to store the kubeconfig: %w", err)
}
Expand Down Expand Up @@ -498,7 +497,7 @@ func sshAgent(publicKeyPath string) (ssh.AuthMethod, func() error) {
return nil, sshAgentConn.Close
}

pubkey, err := ioutil.ReadFile(publicKeyPath)
pubkey, err := os.ReadFile(publicKeyPath)
if err != nil {
return nil, sshAgentConn.Close
}
Expand All @@ -521,7 +520,7 @@ func sshAgent(publicKeyPath string) (ssh.AuthMethod, func() error) {
func loadPublickey(path string) (ssh.AuthMethod, func() error, error) {
noopCloseFunc := func() error { return nil }

key, err := ioutil.ReadFile(path)
key, err := os.ReadFile(path)
if err != nil {
return nil, noopCloseFunc, fmt.Errorf("unable to read file: %s, %s", path, err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"errors"
"io/ioutil"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -48,7 +47,7 @@ kfFJfrUjElq6Bx9oPPxc2vD40gqnYL57A+Y+X+A0kL4fO7pfh2VxOw==
func Test_loadPublickeyEncrypted(t *testing.T) {
want := &ssh.PassphraseMissingError{}

tmpfile, err := ioutil.TempFile("", "key")
tmpfile, err := os.CreateTemp("", "key")
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit ca80ac6

Please sign in to comment.