Skip to content

Commit

Permalink
adding a default location to look for .kube/config in home directory …
Browse files Browse the repository at this point in the history
…if the environment variable isn't defined
  • Loading branch information
juliev0 committed Feb 1, 2022
1 parent 725d8ce commit 651ee6e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/e2e/fixtures/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 651ee6e

Please sign in to comment.