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

Replace ioutil with io and os for cluster/gce/gci #106018

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions cluster/gce/gci/apiserver_kms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -128,7 +127,7 @@ func TestEncryptionProviderConfig(t *testing.T) {
c.t.Fatalf("Expected encryption provider config to be written to %s, but stat failed with error: %v", p, err)
}

got, err := ioutil.ReadFile(p)
got, err := os.ReadFile(p)
if err != nil {
c.t.Fatalf("Failed to read encryption provider config %s", p)
}
Expand Down
5 changes: 2 additions & 3 deletions cluster/gce/gci/append_or_replace_prefixed_line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package gci

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"testing"
Expand Down Expand Up @@ -155,7 +154,7 @@ jelloworld
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
f, err := ioutil.TempFile("", "append_or_replace_test")
f, err := os.CreateTemp("", "append_or_replace_test")
if err != nil {
t.Fatalf("Failed to create temp file: %v", err)
}
Expand All @@ -170,7 +169,7 @@ jelloworld
if err != nil {
t.Fatalf("Failed to run command: %v: %s", err, stderr)
}
got, err := ioutil.ReadFile(f.Name())
got, err := os.ReadFile(f.Name())
if err != nil {
t.Fatalf("Failed to read file contents: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cluster/gce/gci/audit_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package gci

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

Expand All @@ -40,7 +40,7 @@ func init() {
}

func TestCreateMasterAuditPolicy(t *testing.T) {
baseDir, err := ioutil.TempDir("", "configure-helper-test") // cleaned up by c.tearDown()
baseDir, err := os.MkdirTemp("", "configure-helper-test") // cleaned up by c.tearDown()
require.NoError(t, err, "Failed to create temp directory")

policyFile := filepath.Join(baseDir, "audit_policy.yaml")
Expand Down
5 changes: 2 additions & 3 deletions cluster/gce/gci/configure_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package gci
import (
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -56,7 +55,7 @@ func newManifestTestCase(t *testing.T, manifest, funcName string, auxManifests [
manifestFuncName: funcName,
}

d, err := ioutil.TempDir("", "configure-helper-test")
d, err := os.MkdirTemp("", "configure-helper-test")
if err != nil {
c.t.Fatalf("Failed to create temp directory: %v", err)
}
Expand Down Expand Up @@ -143,7 +142,7 @@ func (c *ManifestTestCase) mustCreateEnv(env interface{}, target string, templat
}

func (c *ManifestTestCase) mustLoadPodFromManifest() {
json, err := ioutil.ReadFile(c.manifestDestination)
json, err := os.ReadFile(c.manifestDestination)
if err != nil {
c.t.Fatalf("Failed to read manifest: %s, %v", c.manifestDestination, err)
}
Expand Down