Skip to content

Commit

Permalink
Fix deprecated functions
Browse files Browse the repository at this point in the history
Replace `ioutil` deprecated functions with their suggested replacements.
  • Loading branch information
HeavyWombat committed Oct 18, 2022
1 parent 7eb7815 commit 214fdd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions pkg/havener/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package havener

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -86,7 +85,7 @@ func isSystemNamespace(namespace string) bool {
}

func clusterName(kubeConfig string) (string, error) {
data, err := ioutil.ReadFile(kubeConfig)
data, err := os.ReadFile(kubeConfig)
if err != nil {
return "", err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/havener/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -239,7 +238,7 @@ func (h *Hvnr) retrieveFilesFromPod(pod *corev1.Pod, baseDir string, findCommand

for _, container := range pod.Spec.Containers {
// Ignore all container that have no shell available
if err := h.PodExec(pod, container.Name, []string{"/bin/sh", "-c", "true"}, nil, ioutil.Discard, nil, false); err != nil {
if err := h.PodExec(pod, container.Name, []string{"/bin/sh", "-c", "true"}, nil, io.Discard, nil, false); err != nil {
continue
}

Expand Down Expand Up @@ -392,7 +391,7 @@ func (h *Hvnr) writeDescribePodToDisk(pod *corev1.Pod, baseDir string) error {
return err
}

return ioutil.WriteFile(
return os.WriteFile(
filepath.Join(baseDir, pod.Name, "pod-describe.output"),
[]byte(description),
0644,
Expand All @@ -419,7 +418,7 @@ func (h *Hvnr) saveDeploymentYAML(pod *corev1.Pod, baseDir string) error {
return err
}

return ioutil.WriteFile(
return os.WriteFile(
filepath.Join(baseDir, pod.Name, "pod.yaml"),
buf.Bytes(),
0644,
Expand Down

0 comments on commit 214fdd5

Please sign in to comment.