Skip to content

Commit

Permalink
Remove warning message regarding the current kubecontext while deleti…
Browse files Browse the repository at this point in the history
…ng the tanzu context

- Since CLI is using local kubeconfig file instead of default kubeconfig, warning message regarding deletion of current kubecontext doesn't have a relevance.

Signed-off-by: Prem Kumar Kalle <[email protected]>
  • Loading branch information
prkalle committed May 22, 2024
1 parent 078dcde commit 53367e2
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions pkg/auth/utils/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/imdario/mergo"
"github.com/pkg/errors"
"k8s.io/client-go/tools/clientcmd"

"github.com/vmware-tanzu/tanzu-plugin-runtime/log"
)

func GetDefaultKubeConfigFile() string {
Expand Down Expand Up @@ -91,19 +89,13 @@ func DeleteContextFromKubeConfig(kubeconfigPath, context string) error {
delete(config.Clusters, clusterName)
delete(config.AuthInfos, userName)

shouldWarn := false
if config.CurrentContext == context {
config.CurrentContext = ""
shouldWarn = true
}
err = clientcmd.WriteToFile(*config, kubeconfigPath)
if err != nil {
return errors.Wrapf(err, "failed to delete the kubeconfig context '%s' ", context)
}

if shouldWarn {
log.Warningf("WARNING: this removed your active context, use \"kubectl config use-context\" to select a different one")
}

return nil
}

0 comments on commit 53367e2

Please sign in to comment.