Skip to content

Commit

Permalink
Merge pull request #1286 from ahrtr/replace_ioutil_with_os_io
Browse files Browse the repository at this point in the history
Replace ioutil with io and os
  • Loading branch information
k8s-ci-robot authored Nov 3, 2021
2 parents 75d28b7 + 241b880 commit acd631e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions pkg/manager/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package manager

import (
"io/ioutil"
"os"
"strings"
"time"
Expand Down Expand Up @@ -111,7 +110,7 @@ func (o *Options) defaults() {

if ns, ok := os.LookupEnv("POD_NAMESPACE"); ok {
o.PodNamespace = ns
} else if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
} else if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
if ns := strings.TrimSpace(string(data)); len(ns) > 0 {
o.PodNamespace = ns
}
Expand All @@ -121,7 +120,7 @@ func (o *Options) defaults() {
}

func (o *Options) getCredentials() map[string]string {
file, err := ioutil.ReadFile(o.CredentialsFile)
file, err := os.ReadFile(o.CredentialsFile)
if err != nil {
o.Logger.Error(err, "error opening credentials file")
return map[string]string{}
Expand Down
3 changes: 1 addition & 2 deletions pkg/manager/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package manager

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

Expand Down Expand Up @@ -58,7 +57,7 @@ password: '%s'
// for linting reasons
test := tt
content := fmt.Sprintf(contentFmt, tt.username, tt.password)
tmpFile, err := ioutil.TempFile("", "creds")
tmpFile, err := os.CreateTemp("", "creds")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/log_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -150,5 +149,5 @@ func readPrivateKey() ([]byte, error) {
return nil, errors.Errorf("private key information missing. Please set %s environment variable", VSpherePrivateKeyFilePath)
}

return ioutil.ReadFile(privateKeyFilePath)
return os.ReadFile(privateKeyFilePath)
}
3 changes: 1 addition & 2 deletions test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
goctx "context"
"fmt"
"go/build"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -240,7 +239,7 @@ func (t *TestEnvironment) CreateKubeconfigSecret(ctx goctx.Context, cluster *clu
}

func getFilePathToCAPICRDs(root string) string {
modBits, err := ioutil.ReadFile(filepath.Join(root, "go.mod"))
modBits, err := os.ReadFile(filepath.Join(root, "go.mod"))
if err != nil {
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
package helpers

import (
"io/ioutil"
"net"
"os"
"path"
"path/filepath"
goruntime "runtime"
Expand Down Expand Up @@ -82,7 +82,7 @@ func initializeWebhookInEnvironment() {
// Get the root of the current file to use in CRD paths.
_, filename, _, _ := goruntime.Caller(0) //nolint
root := path.Join(path.Dir(filename), "..", "..")
configyamlFile, err := ioutil.ReadFile(filepath.Join(root, "config", "webhook", "manifests.yaml"))
configyamlFile, err := os.ReadFile(filepath.Join(root, "config", "webhook", "manifests.yaml"))
if err != nil {
klog.Fatalf("Failed to read core webhook configuration file: %v ", err)
}
Expand Down

0 comments on commit acd631e

Please sign in to comment.