File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,14 @@ func PathFromEnv() string {
8787 if kubeConfigEnv == "" {
8888 return constants .KubeconfigPath
8989 }
90- return filepath .SplitList (kubeConfigEnv )[0 ]
90+ kubeConfigFiles := filepath .SplitList (kubeConfigEnv )
91+ for _ , kubeConfigFile := range kubeConfigFiles {
92+ if kubeConfigFile != "" {
93+ return kubeConfigFile
94+ }
95+ glog .Infof ("Ignoring empty entry in %s env var" , constants .KubeconfigEnvVar )
96+ }
97+ return constants .KubeconfigPath
9198}
9299
93100// extractIP returns the IP address stored for minikube in the kubeconfig specified
Original file line number Diff line number Diff line change @@ -555,11 +555,23 @@ func TestGetKubeConfigPath(t *testing.T) {
555555 input : "/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
556556 want : "/home/fake/.kube/.kubeconfig" ,
557557 },
558+ {
559+ input : ":/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
560+ want : "/home/fake/.kube/.kubeconfig" ,
561+ },
562+ {
563+ input : ":" ,
564+ want : "$HOME/.kube/config" ,
565+ },
566+ {
567+ input : "" ,
568+ want : "$HOME/.kube/config" ,
569+ },
558570 }
559571
560572 for _ , test := range tests {
561573 os .Setenv (clientcmd .RecommendedConfigPathEnvVar , test .input )
562- if result := PathFromEnv (); result != test .want {
574+ if result := PathFromEnv (); result != os . ExpandEnv ( test .want ) {
563575 t .Errorf ("Expected first splitted chunk, got: %s" , result )
564576 }
565577 }
You can’t perform that action at this time.
0 commit comments