From 895f62dfae02c6c7c5e72bbdab58da792eaef883 Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Sat, 20 Apr 2024 19:08:08 -0400 Subject: [PATCH] Agent install command broke when auth-less You can technically run `plural cd install` w/o authenticating to the console, but the new global settings fetch breaks that. Make that code a bit more defensive --- cmd/plural/cd.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/plural/cd.go b/cmd/plural/cd.go index 77f8a1ae8..ba0b92187 100644 --- a/cmd/plural/cd.go +++ b/cmd/plural/cd.go @@ -97,6 +97,9 @@ func (p *Plural) handleInstallDeploymentsOperator(c *cli.Context) error { } } + // we don't care if this fails to init as this command can be auth-less + _ = p.InitConsoleClient(consoleToken, consoleURL) + return p.doInstallOperator(c.String("url"), c.String("token"), c.String("values")) } @@ -121,13 +124,12 @@ func (p *Plural) doInstallOperator(url, token, values string) error { vals := map[string]interface{}{} globalVals := map[string]interface{}{} - settings, err := p.ConsoleClient.GetGlobalSettings() - if err != nil { - return err - } - if settings != nil && settings.AgentHelmValues != nil { - if err := yaml.Unmarshal([]byte(*settings.AgentHelmValues), &globalVals); err != nil { - return err + if p.ConsoleClient != nil { + settings, err := p.ConsoleClient.GetGlobalSettings() + if err == nil && settings != nil && settings.AgentHelmValues != nil { + if err := yaml.Unmarshal([]byte(*settings.AgentHelmValues), &globalVals); err != nil { + return err + } } }