From f2e7d5477f076789da5d0e95fe61a56ddb939f5a Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Wed, 22 Sep 2021 13:38:34 +0800 Subject: refactor: move from io/ioutil to io and os package (#17109) The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun Co-authored-by: techknowlogick --- integrations/git_helper_for_declarative_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'integrations/git_helper_for_declarative_test.go') diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go index 5a5b1314c6..9da5c05f94 100644 --- a/integrations/git_helper_for_declarative_test.go +++ b/integrations/git_helper_for_declarative_test.go @@ -7,7 +7,6 @@ package integrations import ( "context" "fmt" - "io/ioutil" "net" "net/http" "net/url" @@ -28,7 +27,7 @@ import ( func withKeyFile(t *testing.T, keyname string, callback func(string)) { - tmpDir, err := ioutil.TempDir("", "key-file") + tmpDir, err := os.MkdirTemp("", "key-file") assert.NoError(t, err) defer util.RemoveAll(tmpDir) @@ -39,7 +38,7 @@ func withKeyFile(t *testing.T, keyname string, callback func(string)) { err = ssh.GenKeyPair(keyFile) assert.NoError(t, err) - err = ioutil.WriteFile(path.Join(tmpDir, "ssh"), []byte("#!/bin/bash\n"+ + err = os.WriteFile(path.Join(tmpDir, "ssh"), []byte("#!/bin/bash\n"+ "ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\" \"$@\""), 0700) assert.NoError(t, err) @@ -125,7 +124,7 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) { func doGitCloneFail(u *url.URL) func(*testing.T) { return func(t *testing.T) { - tmpDir, err := ioutil.TempDir("", "doGitCloneFail") + tmpDir, err := os.MkdirTemp("", "doGitCloneFail") assert.NoError(t, err) defer util.RemoveAll(tmpDir) assert.Error(t, git.Clone(u.String(), tmpDir, git.CloneRepoOptions{})) @@ -139,7 +138,7 @@ func doGitInitTestRepository(dstPath string) func(*testing.T) { return func(t *testing.T) { // Init repository in dstPath assert.NoError(t, git.InitRepository(dstPath, false)) - assert.NoError(t, ioutil.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0644)) + assert.NoError(t, os.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0644)) assert.NoError(t, git.AddChanges(dstPath, true)) signature := git.Signature{ Email: "test@example.com", -- cgit v1.2.3