Commit 5cfcb8f 1 parent 1842311 commit 5cfcb8f Copy full SHA for 5cfcb8f
File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -100,5 +100,12 @@ func GetKubeConfigPath() string {
100
100
if kubeConfigEnv == "" {
101
101
return constants .KubeconfigPath
102
102
}
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
104
111
}
Original file line number Diff line number Diff line change @@ -36,11 +36,19 @@ func TestGetKubeConfigPath(t *testing.T) {
36
36
input : "/home/fake/.kube/.kubeconfig:/home/fake2/.kubeconfig" ,
37
37
want : "/home/fake/.kube/.kubeconfig" ,
38
38
},
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
+ },
39
47
}
40
48
41
49
for _ , test := range tests {
42
50
os .Setenv (clientcmd .RecommendedConfigPathEnvVar , test .input )
43
- if result := GetKubeConfigPath (); result != test .want {
51
+ if result := GetKubeConfigPath (); result != os . ExpandEnv ( test .want ) {
44
52
t .Errorf ("Expected first splitted chunk, got: %s" , result )
45
53
}
46
54
}
You can’t perform that action at this time.
0 commit comments