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

Remove deprecated ioutil #452

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
7 changes: 3 additions & 4 deletions cmd/kubernetes/kubernetes_app_remove.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ package kubernetes
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@@ -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 {
3 changes: 1 addition & 2 deletions cmd/sshkey/ssh_key_create.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package sshkey

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

"github.com/civo/cli/common"
@@ -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)
5 changes: 2 additions & 3 deletions utility/kubernetes.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package utility

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@@ -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)
}
@@ -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
}