File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -100,5 +100,12 @@ func GetKubeConfigPath() string {
100100 if kubeConfigEnv == "" {
101101 return constants .KubeconfigPath
102102 }
103- return filepath .SplitList (kubeConfigEnv )[0 ]
103+ kubeConfigFiles := filepath .SplitList (kubeConfigEnv )
104+ for _ , kubeConfigFile := range kubeConfigFiles {
105+ if kubeConfigFile != "" {
106+ return kubeConfigFile
107+ }
108+ glog .Infof ("Ignoring empty entry in %s env var" , constants .KubeconfigEnvVar )
109+ }
110+ return constants .KubeconfigPath
104111}
Original file line number Diff line number Diff line change @@ -36,11 +36,19 @@ func TestGetKubeConfigPath(t *testing.T) {
3636 input : "/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
3737 want : "/home/fake/.kube/.kubeconfig" ,
3838 },
39+ {
40+ input : ":/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
41+ want : "/home/fake/.kube/.kubeconfig" ,
42+ },
43+ {
44+ input : ":" ,
45+ want : "$HOME/.kube/config" ,
46+ },
3947 }
4048
4149 for _ , test := range tests {
4250 os .Setenv (clientcmd .RecommendedConfigPathEnvVar , test .input )
43- if result := GetKubeConfigPath (); result != test .want {
51+ if result := GetKubeConfigPath (); result != os . ExpandEnv ( test .want ) {
4452 t .Errorf ("Expected first splitted chunk, got: %s" , result )
4553 }
4654 }
You can’t perform that action at this time.
0 commit comments