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 (
"io"
"io/ioutil"
"os"
"path/filepath"
@ -28,7 +27,7 @@ import (
// AtomicWriteFile atomically (as atomic as os.Rename allows) writes a file to a
// disk.
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 {
return err
}

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

@ -18,7 +18,6 @@ package postrender
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -167,7 +166,7 @@ func setupTestingScript(t *testing.T) (filepath string, cleanup func()) {
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 {
t.Fatalf("unable to create tempfile for testing: %s", err)
}

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

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

@ -17,7 +17,6 @@ limitations under the License.
package repo
import (
"io/ioutil"
"os"
"strings"
"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 {
t.Errorf("failed to create test-file (%v)", err)
}

Loading…
Cancel
Save