replace deprecated method call ioutil.TempFile to os.CreateTemp

Signed-off-by: Igor Manushin <igor.manushin@gmail.com>
pull/11503/head
Igor Manushin 3 years ago
parent 269dd247d0
commit 7b9e1e0e5f

@ -18,7 +18,6 @@ package fileutil
import ( import (
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -28,7 +27,7 @@ import (
// AtomicWriteFile atomically (as atomic as os.Rename allows) writes a file to a // AtomicWriteFile atomically (as atomic as os.Rename allows) writes a file to a
// disk. // disk.
func AtomicWriteFile(filename string, reader io.Reader, mode os.FileMode) error { func AtomicWriteFile(filename string, reader io.Reader, mode os.FileMode) error {
tempFile, err := ioutil.TempFile(filepath.Split(filename)) tempFile, err := os.CreateTemp(filepath.Split(filename))
if err != nil { if err != nil {
return err return err
} }

@ -17,7 +17,6 @@ limitations under the License.
package action package action
import ( import (
"io/ioutil"
"os" "os"
"path" "path"
"testing" "testing"
@ -71,7 +70,7 @@ func TestPassphraseFileFetcher_WithInvalidStdin(t *testing.T) {
directory := ensure.TempDir(t) directory := ensure.TempDir(t)
defer os.RemoveAll(directory) defer os.RemoveAll(directory)
stdin, err := ioutil.TempFile(directory, "non-existing") stdin, err := os.CreateTemp(directory, "non-existing")
if err != nil { if err != nil {
t.Fatal("Unable to create test file", err) t.Fatal("Unable to create test file", err)
} }

@ -18,7 +18,6 @@ package postrender
import ( import (
"bytes" "bytes"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -167,7 +166,7 @@ func setupTestingScript(t *testing.T) (filepath string, cleanup func()) {
tempdir := ensure.TempDir(t) tempdir := ensure.TempDir(t)
f, err := ioutil.TempFile(tempdir, "post-render-test.sh") f, err := os.CreateTemp(tempdir, "post-render-test.sh")
if err != nil { if err != nil {
t.Fatalf("unable to create tempfile for testing: %s", err) t.Fatalf("unable to create tempfile for testing: %s", err)
} }

@ -277,7 +277,7 @@ func TestDecodeSignature(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
f, err := ioutil.TempFile("", "helm-test-sig-") f, err := os.CreateTemp("", "helm-test-sig-")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -151,7 +151,7 @@ func TestIndexCustomSchemeDownload(t *testing.T) {
repo.CachePath = ensure.TempDir(t) repo.CachePath = ensure.TempDir(t)
defer os.RemoveAll(repo.CachePath) defer os.RemoveAll(repo.CachePath)
tempIndexFile, err := ioutil.TempFile("", "test-repo") tempIndexFile, err := os.CreateTemp("", "test-repo")
if err != nil { if err != nil {
t.Fatalf("Failed to create temp index file: %v", err) t.Fatalf("Failed to create temp index file: %v", err)
} }

@ -17,7 +17,6 @@ limitations under the License.
package repo package repo
import ( import (
"io/ioutil"
"os" "os"
"strings" "strings"
"testing" "testing"
@ -198,7 +197,7 @@ func TestWriteFile(t *testing.T) {
}, },
) )
file, err := ioutil.TempFile("", "helm-repo") file, err := os.CreateTemp("", "helm-repo")
if err != nil { if err != nil {
t.Errorf("failed to create test-file (%v)", err) t.Errorf("failed to create test-file (%v)", err)
} }

Loading…
Cancel
Save