From c0c9d78ca0091e8e9d07cc1ed9d6f941ba35205b Mon Sep 17 00:00:00 2001 From: seemywings Date: Tue, 30 Apr 2024 15:30:59 -0400 Subject: [PATCH 1/2] adding version to install action of InstallAgent declaration --- pkg/console/agent.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/console/agent.go b/pkg/console/agent.go index 90488961..658dd85b 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,7 +39,11 @@ func InstallAgent(url, token, namespace string, values map[string]interface{}) e return err } - cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings) + /// new action to configure the chart version + newInstallAction := action.NewInstall(helmConfig) + newInstallAction.ChartPathOptions.Version = version + + cp, err := newInstallAction.ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings) if err != nil { return err } From 079707fb500788b91cc4f992318be7944ee00381 Mon Sep 17 00:00:00 2001 From: seemywings Date: Wed, 1 May 2024 14:26:53 -0400 Subject: [PATCH 2/2] Specify Agent Version in Deployment Settings get the version from global setting before updating the agent --- cmd/plural/cd.go | 13 +++++++++---- go.mod | 2 +- go.sum | 2 ++ pkg/console/agent.go | 3 +-- 4 files changed, 13 insertions(+), 7 deletions(-) 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 658dd85b..f6ed5d47 100644 --- a/pkg/console/agent.go +++ b/pkg/console/agent.go @@ -39,11 +39,10 @@ func InstallAgent(url, token, namespace, version string, values map[string]inter return err } - /// new action to configure the chart version newInstallAction := action.NewInstall(helmConfig) newInstallAction.ChartPathOptions.Version = version - cp, err := newInstallAction.ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings) + cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings) if err != nil { return err }