[setup] create k8s cluster config file in tempdir (#5)
diff --git a/internal/components/cleanup/kind.go b/internal/components/cleanup/kind.go
index 2f7c33a..2fc4de2 100644
--- a/internal/components/cleanup/kind.go
+++ b/internal/components/cleanup/kind.go
@@ -48,9 +48,9 @@
}
logger.Log.Info("delete kind cluster succeeded")
- k8sConfigFile := constant.K8sClusterConfigFile
- logger.Log.Infof("deleting k8s cluster config file:%s", k8sConfigFile)
- err := os.Remove(k8sConfigFile)
+ kubeConfigPath := constant.K8sClusterConfigFilePath
+ logger.Log.Infof("deleting k8s cluster config file:%s", kubeConfigPath)
+ err := os.Remove(kubeConfigPath)
if err != nil {
logger.Log.Errorf("delete k8s cluster config file failed")
return err
diff --git a/internal/components/setup/kind.go b/internal/components/setup/kind.go
index 96e5edd..9f7b156 100644
--- a/internal/components/setup/kind.go
+++ b/internal/components/setup/kind.go
@@ -94,7 +94,7 @@
func createKindCluster(kindConfigPath string) error {
// the config file name of the k8s cluster that kind create
- kubeConfigPath = constant.K8sClusterConfigFile
+ kubeConfigPath = constant.K8sClusterConfigFilePath
args := []string{"create", "cluster", "--config", kindConfigPath, "--kubeconfig", kubeConfigPath}
logger.Log.Info("creating kind cluster...")
diff --git a/internal/constant/kind.go b/internal/constant/kind.go
index 7b8586d..b6bb7cb 100644
--- a/internal/constant/kind.go
+++ b/internal/constant/kind.go
@@ -18,19 +18,24 @@
package constant
-import "time"
+import (
+ "os"
+ "path"
+ "time"
+)
const (
Kind = "kind"
KindCommand = "kind"
KindClusterDefaultName = "kind"
E2EDefaultFile = "e2e.yaml"
- K8sClusterConfigFile = "e2e-k8s.config"
+ K8sClusterConfigFileName = "e2e-k8s.config"
DefaultWaitTimeout = 600 * time.Second
SingleDefaultWaitTimeout = 30 * 60 * time.Second
)
var (
- True = true
- False = false
+ True = true
+ False = false
+ K8sClusterConfigFilePath = path.Join(os.TempDir(), K8sClusterConfigFileName)
)
diff --git a/internal/util/which.go b/internal/util/utils.go
similarity index 100%
rename from internal/util/which.go
rename to internal/util/utils.go