Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove refs to deprecated io/ioutil #411

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading