Merge pull request #32613 from madhusudancs/fed-clientcmd-bug-31947-fix

Automatic merge from submit-queue

Fix clientcmd for a non-host cluster client running in a pod. 

This is based on @errordeveloper's PR #32438. It fixes a case where default config is invalid and original config, i.e. `mergedConfig` is empty. It also adds a test for the case where default config is invalid and original config is neither invalid nor empty.

cc @errordeveloper @kubernetes/sig-cluster-federation @pwittrock @colhom
This commit is contained in:
Kubernetes Submit Queue 2016-09-14 13:10:27 -07:00 committed by GitHub
commit 9aca785bc8
2 changed files with 15 additions and 2 deletions

View File

@ -114,8 +114,11 @@ func (config *DeferredLoadingClientConfig) ClientConfig() (*restclient.Config, e
// "empty due to defaults"
// TODO: this shouldn't be a global - the client config rules should be
// handling this.
defaultConfig, err := DefaultClientConfig.ClientConfig()
if err == nil && !reflect.DeepEqual(mergedConfig, defaultConfig) {
defaultConfig, defErr := DefaultClientConfig.ClientConfig()
if IsConfigurationInvalid(defErr) && !IsEmptyConfig(err) {
return mergedConfig, nil
}
if defErr == nil && !reflect.DeepEqual(mergedConfig, defaultConfig) {
return mergedConfig, nil
}
}

View File

@ -174,6 +174,16 @@ func TestInClusterConfig(t *testing.T) {
result: config2,
err: nil,
},
"in-cluster not checked when default is invalid": {
defaultConfig: &DefaultClientConfig,
clientConfig: &testClientConfig{config: config2},
icc: &testICC{},
checkedICC: false,
result: config2,
err: nil,
},
}
for name, test := range testCases {