Skip to content

Commit

Permalink
Agent install command broke when auth-less
Browse files Browse the repository at this point in the history
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
  • Loading branch information
michaeljguarino committed Apr 20, 2024
1 parent 8bfbbd5 commit 895f62d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cmd/plural/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

Expand All @@ -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
}
}
}

Expand Down

0 comments on commit 895f62d

Please sign in to comment.