Namespace implements ClientConfig
()
| 307 | |
| 308 | // Namespace implements ClientConfig |
| 309 | func (config *DirectClientConfig) Namespace() (string, bool, error) { |
| 310 | if config.overrides != nil && config.overrides.Context.Namespace != "" { |
| 311 | // In the event we have an empty config but we do have a namespace override, we should return |
| 312 | // the namespace override instead of having config.ConfirmUsable() return an error. This allows |
| 313 | // things like in-cluster clients to execute `kubectl get pods --namespace=foo` and have the |
| 314 | // --namespace flag honored instead of being ignored. |
| 315 | return config.overrides.Context.Namespace, true, nil |
| 316 | } |
| 317 | |
| 318 | if err := config.ConfirmUsable(); err != nil { |
| 319 | return "", false, err |
| 320 | } |
| 321 | |
| 322 | configContext, err := config.getContext() |
| 323 | if err != nil { |
| 324 | return "", false, err |
| 325 | } |
| 326 | |
| 327 | if len(configContext.Namespace) == 0 { |
| 328 | return "default", false, nil |
| 329 | } |
| 330 | |
| 331 | return configContext.Namespace, false, nil |
| 332 | } |
| 333 | |
| 334 | // ConfigAccess implements ClientConfig |
| 335 | func (config *DirectClientConfig) ConfigAccess() ConfigAccess { |