mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
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:
commit
9aca785bc8
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user