mirror of https://github.com/k3s-io/k3s
Merge pull request #73816 from mkumatag/fix_tmpdir
Use ioutil.TempDir for temporary dir creationpull/564/head
commit
920045652d
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -415,8 +416,12 @@ func TestProcessHostnameOverrideFlag(t *testing.T) {
|
||||||
|
|
||||||
func TestConfigChange(t *testing.T) {
|
func TestConfigChange(t *testing.T) {
|
||||||
setUp := func() (*os.File, string, error) {
|
setUp := func() (*os.File, string, error) {
|
||||||
tempDir := os.TempDir()
|
tempDir, err := ioutil.TempDir("", "kubeproxy-config-change")
|
||||||
file, err := ioutil.TempFile(tempDir, "kube-proxy-config-")
|
if err != nil {
|
||||||
|
return nil, "", fmt.Errorf("Unable to create temporary directory: %v", err)
|
||||||
|
}
|
||||||
|
fullPath := filepath.Join(tempDir, "kube-proxy-config")
|
||||||
|
file, err := os.Create(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("unexpected error when creating temp file: %v", err)
|
return nil, "", fmt.Errorf("unexpected error when creating temp file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue