Content-Length: 279211 | pFad | http://github.com/kubernetes/kubernetes/commit/58ea7d6c2c2eb3544130b95bef93cd16dbdbdd2a

75 kubectl: Fix in-cluster config not loaded on flags · kubernetes/kubernetes@58ea7d6 · GitHub
Skip to content

Commit 58ea7d6

Browse files
committed
kubectl: Fix in-cluster config not loaded on flags
In-cluster config is now being skipped when certain command line flags are specified, like --request-timeout. This is now fixed and in-cluster config is loaded even when such a flag is specified.
1 parent 3044a4c commit 58ea7d6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

staging/src/k8s.io/client-go/tools/clientcmd/merged_client_builder.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,17 @@ func (config *DeferredLoadingClientConfig) ClientConfig() (*restclient.Config, e
109109
return nil, err
110110
}
111111
case mergedConfig != nil:
112-
// the configuration is valid, but if this is equal to the defaults we should try
113-
// in-cluster configuration
114-
if !config.loader.IsDefaultConfig(mergedConfig) {
112+
// The configuration is valid, but we should try in-cluster configuration if the merged config is empty.
113+
// You may feel like using config.loader.IsDefaultConfig(mergedConfig), but that does not work.
114+
// The loaded config becomes non-default as soon as any override is used, immediately disabling in-cluster.
115+
// So for our purpose, the loaded config is default as long as it is empty.
116+
c, err := mergedClientConfig.RawConfig()
117+
if err != nil {
118+
return nil, err
119+
}
120+
121+
// Return the merged config when it's not empty.
122+
if len(c.Contexts) != 0 || len(c.Clusters) != 0 || len(c.AuthInfos) != 0 {
115123
return mergedConfig, nil
116124
}
117125
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kubernetes/kubernetes/commit/58ea7d6c2c2eb3544130b95bef93cd16dbdbdd2a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy