diff --git a/cmd/plural/cd.go b/cmd/plural/cd.go index ba0b9218..a9af5068 100644 --- a/cmd/plural/cd.go +++ b/cmd/plural/cd.go @@ -3,6 +3,7 @@ package plural import ( "fmt" "os" + "strings" "github.com/pluralsh/plural-cli/pkg/cd" "github.com/pluralsh/plural-cli/pkg/config" @@ -123,12 +124,16 @@ func (p *Plural) doInstallOperator(url, token, values string) error { vals := map[string]interface{}{} globalVals := map[string]interface{}{} + version := "" 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 + if err == nil && settings != nil { + version = strings.Trim(settings.AgentVsn, "v") + if settings.AgentHelmValues != nil { + if err := yaml.Unmarshal([]byte(*settings.AgentHelmValues), &globalVals); err != nil { + return err + } } } } @@ -139,7 +144,7 @@ func (p *Plural) doInstallOperator(url, token, values string) error { } } vals = algorithms.Merge(vals, globalVals) - err = console.InstallAgent(url, token, console.OperatorNamespace, vals) + err = console.InstallAgent(url, token, console.OperatorNamespace, version, vals) if err == nil { utils.Success("deployment operator installed successfully\n") } diff --git a/go.mod b/go.mod index 518c8d21..72188e3b 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/packethost/packngo v0.29.0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pluralsh/cluster-api-migration v0.2.15 - github.com/pluralsh/console-client-go v0.1.17 + github.com/pluralsh/console-client-go v0.5.3 github.com/pluralsh/gqlclient v1.11.0 github.com/pluralsh/plural-operator v0.5.5 github.com/pluralsh/polly v0.1.7 diff --git a/go.sum b/go.sum index 7bf24a40..2f64a380 100644 --- a/go.sum +++ b/go.sum @@ -1426,6 +1426,8 @@ github.com/pluralsh/cluster-api-migration v0.2.15 h1:TIfusD+wnhZTGmwNfIlKlKJOT2d github.com/pluralsh/cluster-api-migration v0.2.15/go.mod h1:J6lEvC/70KouikX16mE331cxc3y3sBwtmfHGwZqu06w= github.com/pluralsh/console-client-go v0.1.17 h1:QMtnWdRvV13/sND/CFjFBUR8nyg3JJgwXReSyM6bK7A= github.com/pluralsh/console-client-go v0.1.17/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo= +github.com/pluralsh/console-client-go v0.5.3 h1:RB4XtKlvh8+BM5o1o0h+W6zHculBGbL6q5lI/yRnqJE= +github.com/pluralsh/console-client-go v0.5.3/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo= github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E= github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s= github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA= diff --git a/pkg/console/agent.go b/pkg/console/agent.go index 90488961..f6ed5d47 100644 --- a/pkg/console/agent.go +++ b/pkg/console/agent.go @@ -20,7 +20,7 @@ const ( OperatorNamespace = "plrl-deploy-operator" ) -func InstallAgent(url, token, namespace string, values map[string]interface{}) error { +func InstallAgent(url, token, namespace, version string, values map[string]interface{}) error { settings := cli.New() vals := map[string]interface{}{ "secrets": map[string]string{ @@ -39,6 +39,9 @@ func InstallAgent(url, token, namespace string, values map[string]interface{}) e return err } + newInstallAction := action.NewInstall(helmConfig) + newInstallAction.ChartPathOptions.Version = version + cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings) if err != nil { return err