From 09cdbf3f9dc7c4d78e6bd4692300cbc0598d6e0f Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 17 Aug 2023 11:51:34 -0400 Subject: [PATCH] use context when switching to kind-porter Signed-off-by: Troy Connor --- tests/kind.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/kind.go b/tests/kind.go index 069d08f..7025db5 100644 --- a/tests/kind.go +++ b/tests/kind.go @@ -99,8 +99,13 @@ func CreateTestCluster() { } } } + homeDir, err := os.UserHomeDir() + if err != nil { + mgx.Must(fmt.Errorf("error retrieving the home directory of the current user %w", err)) + } + kubeConfig := homeDir + "/.kube/config:" + filepath.Join(pwd(), Kubeconfig) - os.Setenv("KUBECONFIG", filepath.Join(pwd(), Kubeconfig)) + os.Setenv("KUBECONFIG", kubeConfig) kindCfgTmpl, err := template.New("kind.config.yaml").Parse(templateKindConfig) if err != nil { mgx.Must(fmt.Errorf("error parsing EnsureKind config template: %w", err)) @@ -127,6 +132,7 @@ func CreateTestCluster() { kubectl("apply", "-f", "-"). Stdin(strings.NewReader(templateLocalRegistry)). Run() + kubectl("config", "use-context", "kind-porter").Run() } // Delete the KIND cluster named porter.