diff options
| author | YTCai <qazxcv367tasi@gmail.com> | 2022-11-16 03:18:09 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 14:18:09 -0500 |
| commit | 1c35fc5b387389051cef132516f8547f7f4e9aaa (patch) | |
| tree | 668e600e615e172a7688eec2f5b41e1d66648fa1 /ext | |
| parent | ccb749f141b100934c550843098c547f21a95fd9 (diff) | |
fix: update application config sample & replace the deprecated ioutil pkg (#492)
* docs: update application config sample
Signed-off-by: CaiYueTing <qazxcv367tasi@gmail.com>
* fix: use os read/write instead of deprecated ioutil read/write package
Signed-off-by: CaiYueTing <qazxcv367tasi@gmail.com>
* fix: use io, os pkg instead of all of the ioutil pkg
Signed-off-by: CaiYueTing <qazxcv367tasi@gmail.com>
Signed-off-by: CaiYueTing <qazxcv367tasi@gmail.com>
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/git/creds.go | 11 | ||||
| -rw-r--r-- | ext/git/git_test.go | 16 |
2 files changed, 13 insertions, 14 deletions
diff --git a/ext/git/creds.go b/ext/git/creds.go index d326277..c8f6493 100644 --- a/ext/git/creds.go +++ b/ext/git/creds.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "fmt" "io" - "io/ioutil" "os" "strconv" "strings" @@ -118,10 +117,10 @@ func (c HTTPSCreds) Environ() (io.Closer, []string, error) { // We need to actually create two temp files, one for storing cert data and // another for storing the key. If we fail to create second fail, the first // must be removed. - certFile, err := ioutil.TempFile(argoio.TempDir, "") + certFile, err := os.CreateTemp(argoio.TempDir, "") if err == nil { defer certFile.Close() - keyFile, err = ioutil.TempFile(argoio.TempDir, "") + keyFile, err = os.CreateTemp(argoio.TempDir, "") if err != nil { removeErr := os.Remove(certFile.Name()) if removeErr != nil { @@ -204,7 +203,7 @@ func (f authFilePaths) Close() error { func (c SSHCreds) Environ() (io.Closer, []string, error) { // use the SHM temp dir from util, more secure - file, err := ioutil.TempFile(argoio.TempDir, "") + file, err := os.CreateTemp(argoio.TempDir, "") if err != nil { return nil, nil, err } @@ -275,10 +274,10 @@ func (g GitHubAppCreds) Environ() (io.Closer, []string, error) { // We need to actually create two temp files, one for storing cert data and // another for storing the key. If we fail to create second fail, the first // must be removed. - certFile, err := ioutil.TempFile(argoio.TempDir, "") + certFile, err := os.CreateTemp(argoio.TempDir, "") if err == nil { defer certFile.Close() - keyFile, err = ioutil.TempFile(argoio.TempDir, "") + keyFile, err = os.CreateTemp(argoio.TempDir, "") if err != nil { removeErr := os.Remove(certFile.Name()) if removeErr != nil { diff --git a/ext/git/git_test.go b/ext/git/git_test.go index 8738b75..de04454 100644 --- a/ext/git/git_test.go +++ b/ext/git/git_test.go @@ -2,7 +2,7 @@ package git import ( "fmt" - "io/ioutil" + "io" "net/http" "os" "path/filepath" @@ -137,11 +137,11 @@ func TestCustomHTTPClient(t *testing.T) { assert.NoError(t, err) assert.NotEqual(t, "", keyFile) - certData, err := ioutil.ReadFile(certFile) + certData, err := os.ReadFile(certFile) assert.NoError(t, err) assert.NotEqual(t, "", string(certData)) - keyData, err := ioutil.ReadFile(keyFile) + keyData, err := os.ReadFile(keyFile) assert.NoError(t, err) assert.NotEqual(t, "", string(keyData)) @@ -245,7 +245,7 @@ func TestLFSClient(t *testing.T) { // TODO(alexmt): dockerize tests in and enabled it t.Skip() - tempDir, err := ioutil.TempDir("", "git-client-lfs-test-") + tempDir, err := os.MkdirTemp("", "git-client-lfs-test-") assert.NoError(t, err) if err == nil { defer func() { _ = os.RemoveAll(tempDir) }() @@ -275,7 +275,7 @@ func TestLFSClient(t *testing.T) { assert.NoError(t, err) if err == nil { defer fileHandle.Close() - text, err := ioutil.ReadAll(fileHandle) + text, err := io.ReadAll(fileHandle) assert.NoError(t, err) if err == nil { assert.Equal(t, "This is not a YAML, sorry.\n", string(text)) @@ -284,7 +284,7 @@ func TestLFSClient(t *testing.T) { } func TestVerifyCommitSignature(t *testing.T) { - p, err := ioutil.TempDir("", "test-verify-commit-sig") + p, err := os.MkdirTemp("", "test-verify-commit-sig") if err != nil { panic(err.Error()) } @@ -343,7 +343,7 @@ func TestNewFactory(t *testing.T) { test.Flaky(t) } - dirName, err := ioutil.TempDir("", "git-client-test-") + dirName, err := os.MkdirTemp("", "git-client-test-") assert.NoError(t, err) defer func() { _ = os.RemoveAll(dirName) }() @@ -381,7 +381,7 @@ func TestNewFactory(t *testing.T) { } func TestListRevisions(t *testing.T) { - dir, err := ioutil.TempDir("", "test-list-revisions") + dir, err := os.MkdirTemp("", "test-list-revisions") if err != nil { panic(err.Error()) } |
