refactor: GetContextOverrideOrCurrent to check if config used

This commit is contained in:
Pasha Sviderski
2026-03-17 20:21:54 +10:00
parent 838839a7e5
commit 1735ef9521
+6 -4
View File
@@ -72,11 +72,13 @@ func (cli *CLI) SetCurrentContext(name string) error {
}
func (cli *CLI) GetContextOverrideOrCurrent() string {
contextName := cli.contextOverride
if contextName == "" {
contextName = cli.Config.CurrentContext
if cli.contextOverride != "" {
return cli.contextOverride
}
return contextName
if cli.Config != nil {
return cli.Config.CurrentContext
}
return ""
}
// ConnectCluster connects to a cluster using the context override or the current context if not specified.