From 0f34941b946996f3931310eaa19b68e4dbd018b5 Mon Sep 17 00:00:00 2001 From: Julie Vogelman Date: Tue, 1 Feb 2022 11:18:09 -0800 Subject: [PATCH] fix: e2e test not recognizing .kube/config (#1581) Signed-off-by: Julie Vogelman --- test/e2e/fixtures/e2e_suite.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/e2e/fixtures/e2e_suite.go b/test/e2e/fixtures/e2e_suite.go index 379f7803a8..2a030db700 100644 --- a/test/e2e/fixtures/e2e_suite.go +++ b/test/e2e/fixtures/e2e_suite.go @@ -56,7 +56,15 @@ type E2ESuite struct { func (s *E2ESuite) SetupSuite() { var err error - kubeConfig, _ := os.LookupEnv(common.EnvVarKubeConfig) + + kubeConfig, found := os.LookupEnv(common.EnvVarKubeConfig) + if !found { + home, _ := os.UserHomeDir() + kubeConfig = home + "/.kube/config" + if _, err := os.Stat(kubeConfig); err != nil && os.IsNotExist(err) { + kubeConfig = "" + } + } s.restConfig, err = common.GetClientConfig(kubeConfig) s.CheckError(err) s.kubeClient, err = kubernetes.NewForConfig(s.restConfig)