From 1735ef9521a4538eb8b358d944f25ed2f0281ec5 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Tue, 17 Mar 2026 20:21:54 +1000 Subject: [PATCH] refactor: GetContextOverrideOrCurrent to check if config used --- internal/cli/cli.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 31381299..e184a98b 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -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.