Skip to content

Commit

Permalink
Remove deprecated ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
fulviodenza committed Aug 22, 2024
1 parent 7bfa08b commit 555f391
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions cmd/kubernetes/kubernetes_app_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kubernetes
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -43,12 +42,12 @@ var kubernetesAppRemoveCmd = &cobra.Command{
}

allApps := strings.Split(args[0], ",")
tmpFile, err := ioutil.TempFile(os.TempDir(), "kubeconfig-")
tmpFile, err := os.CreateTemp(os.TempDir(), "kubeconfig-")
if err != nil {
utility.Error("Cannot create temporary file", err)
utility.Error("Cannot create temporary file: %v", err)
}
if _, err = tmpFile.Write([]byte(kube.KubeConfig)); err != nil {
utility.Error("Failed to write to temporary file", err)
utility.Error("Failed to write to temporary file: %v", err)
}
defer os.Remove(tmpFile.Name())
for _, split := range allApps {
Expand Down
3 changes: 1 addition & 2 deletions cmd/sshkey/ssh_key_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sshkey

import (
"fmt"
"io/ioutil"
"os"

"github.com/civo/cli/common"
Expand All @@ -27,7 +26,7 @@ var sshKeyCreateCmd = &cobra.Command{
}

// reading the file
data, err := ioutil.ReadFile(keyCreate)
data, err := os.ReadFile(keyCreate)
if err != nil {
utility.Error("Reading the SSH key file failed with %s", err)
os.Exit(1)
Expand Down
5 changes: 2 additions & 3 deletions utility/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utility

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -41,7 +40,7 @@ func ObtainKubeConfig(KubeconfigFilename string, civoConfig string, merge bool,

func mergeConfigs(localKubeconfigPath string, k3sconfig []byte, switchContext bool, clusterName string) ([]byte, error) {
// Create a temporary kubeconfig to store the config of the newly create k3s cluster
file, err := ioutil.TempFile(os.TempDir(), "civo-temp-*")
file, err := os.CreateTemp(os.TempDir(), "civo-temp-*")
if err != nil {
return nil, fmt.Errorf("could not generate a temporary file to store the kuebeconfig: %s", err)
}
Expand Down Expand Up @@ -119,7 +118,7 @@ func writeConfig(path string, data []byte, suppressMessage bool, mergeConfigs bo
defer file.Close()
}

writeErr := ioutil.WriteFile(path, data, 0600)
writeErr := os.WriteFile(path, data, 0600)
if writeErr != nil {
return writeErr
}
Expand Down

0 comments on commit 555f391

Please sign in to comment.