From 782409255aca667dd1eec6cd69f4c339e43e4d71 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Thu, 7 Feb 2019 11:42:09 -0500 Subject: [PATCH] Use ioutil.TempDir for temporary dir creating --- cmd/kube-proxy/app/server_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/kube-proxy/app/server_test.go b/cmd/kube-proxy/app/server_test.go index e07cd18b4b..345e783cf2 100644 --- a/cmd/kube-proxy/app/server_test.go +++ b/cmd/kube-proxy/app/server_test.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "reflect" "runtime" "strings" @@ -415,8 +416,12 @@ func TestProcessHostnameOverrideFlag(t *testing.T) { func TestConfigChange(t *testing.T) { setUp := func() (*os.File, string, error) { - tempDir := os.TempDir() - file, err := ioutil.TempFile(tempDir, "kube-proxy-config-") + tempDir, err := ioutil.TempDir("", "kubeproxy-config-change") + 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 { return nil, "", fmt.Errorf("unexpected error when creating temp file: %v", err) }