File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,14 @@ func PathFromEnv() string {
87
87
if kubeConfigEnv == "" {
88
88
return constants .KubeconfigPath
89
89
}
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
91
98
}
92
99
93
100
// 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) {
555
555
input : "/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
556
556
want : "/home/fake/.kube/.kubeconfig" ,
557
557
},
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
+ },
558
570
}
559
571
560
572
for _ , test := range tests {
561
573
os .Setenv (clientcmd .RecommendedConfigPathEnvVar , test .input )
562
- if result := PathFromEnv (); result != test .want {
574
+ if result := PathFromEnv (); result != os . ExpandEnv ( test .want ) {
563
575
t .Errorf ("Expected first splitted chunk, got: %s" , result )
564
576
}
565
577
}
You can’t perform that action at this time.
0 commit comments