Use overridden config when determining if default namespace came from config

Kubernetes-commit: f19399096b8a783b943029c0083af58bdc0f29ee
This commit is contained in:
Jordan Liggitt
2019-01-03 12:26:28 -05:00
committed by Kubernetes Publisher
parent f97fdd8c9d
commit 84dcc145e1
5 changed files with 48 additions and 650 deletions

View File

@@ -150,7 +150,12 @@ func (config *DeferredLoadingClientConfig) Namespace() (string, bool, error) {
// if we got a default namespace, determine whether it was explicit or implicit
if raw, err := mergedKubeConfig.RawConfig(); err == nil {
if context := raw.Contexts[raw.CurrentContext]; context != nil && len(context.Namespace) > 0 {
// determine the current context
currentContext := raw.CurrentContext
if config.overrides != nil && len(config.overrides.CurrentContext) > 0 {
currentContext = config.overrides.CurrentContext
}
if context := raw.Contexts[currentContext]; context != nil && len(context.Namespace) > 0 {
return ns, false, nil
}
}