From 9d2827ea2e2c8bee1a83eca4341b650037e01b5a Mon Sep 17 00:00:00 2001 From: Prem Kumar Kalle Date: Thu, 5 Oct 2023 10:19:00 -0700 Subject: [PATCH] Fix the error message strings for TMC and TAE in CSP authentication Signed-off-by: Prem Kumar Kalle --- pkg/command/context.go | 4 ++-- pkg/command/root.go | 7 +++++++ pkg/pluginmanager/manager.go | 7 ------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/command/context.go b/pkg/command/context.go index 27c583ab0..d2499a05e 100644 --- a/pkg/command/context.go +++ b/pkg/command/context.go @@ -514,14 +514,14 @@ func doCSPAuthAndUpdateContext(c *configtypes.Context, endpointType string) (cla if apiTokenExists { log.Info("API token env var is set") } else { - apiTokenValue, err = promptAPIToken("TAE") + apiTokenValue, err = promptAPIToken(endpointType) if err != nil { return nil, err } } token, err := csp.GetAccessTokenFromAPIToken(apiTokenValue, issuer) if err != nil { - return nil, errors.Wrap(err, "failed to get token from CSP for TAE") + return nil, errors.Wrapf(err, "failed to get token from CSP for %s", endpointType) } claims, err = csp.ParseToken(&oauth2.Token{AccessToken: token.AccessToken}) if err != nil { diff --git a/pkg/command/root.go b/pkg/command/root.go index 1479cb23d..075dcf983 100644 --- a/pkg/command/root.go +++ b/pkg/command/root.go @@ -135,6 +135,13 @@ func newRootCmd() *cobra.Command { // Flag parsing must be deactivated because the root plugin won't know about all flags. DisableFlagParsing: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + // Ensure mutual exclusion in current contexts just in case if any plugins with old + // plugin-runtime sets k8s context as current when tae context is already set as current + if err := utils.EnsureMutualExclusiveCurrentContexts(); err != nil { + return err + } + return nil + if !shouldSkipTelemetryCollection(cmd) { if err := telemetry.Client().UpdateCmdPreRunMetrics(cmd, args); err != nil { telemetry.LogError(err, "") diff --git a/pkg/pluginmanager/manager.go b/pkg/pluginmanager/manager.go index 077255b63..9256ceb38 100644 --- a/pkg/pluginmanager/manager.go +++ b/pkg/pluginmanager/manager.go @@ -975,13 +975,6 @@ func doDeletePluginFromCatalog(pluginName string, target configtypes.Target, cat // If the central-repo is disabled, all discovered plugins will be installed. func SyncPlugins() error { log.Info("Checking for required plugins...") - // ensure the k8s and tae current contexts are mutually exclusive. - // This is required as plugins could call syncPlugins through plugin-runtime - err := utils.EnsureMutualExclusiveCurrentContexts() - if err != nil { - return err - } - errList := make([]error, 0) // We no longer sync standalone plugins. // With a centralized approach to discovering plugins, synchronizing