Skip to content

Commit 97979db

Browse files
author
Kevin Jayne
authored
Kevin/eng 2029 use agent version specified in deployment settings from cli (#508)
* adding version to install action of InstallAgent declaration * Specify Agent Version in Deployment Settings get the version from global setting before updating the agent
1 parent 5eebd09 commit 97979db

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

cmd/plural/cd.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package plural
33
import (
44
"fmt"
55
"os"
6+
"strings"
67

78
"github.com/pluralsh/plural-cli/pkg/cd"
89
"github.com/pluralsh/plural-cli/pkg/config"
@@ -123,12 +124,16 @@ func (p *Plural) doInstallOperator(url, token, values string) error {
123124

124125
vals := map[string]interface{}{}
125126
globalVals := map[string]interface{}{}
127+
version := ""
126128

127129
if p.ConsoleClient != nil {
128130
settings, err := p.ConsoleClient.GetGlobalSettings()
129-
if err == nil && settings != nil && settings.AgentHelmValues != nil {
130-
if err := yaml.Unmarshal([]byte(*settings.AgentHelmValues), &globalVals); err != nil {
131-
return err
131+
if err == nil && settings != nil {
132+
version = strings.Trim(settings.AgentVsn, "v")
133+
if settings.AgentHelmValues != nil {
134+
if err := yaml.Unmarshal([]byte(*settings.AgentHelmValues), &globalVals); err != nil {
135+
return err
136+
}
132137
}
133138
}
134139
}
@@ -139,7 +144,7 @@ func (p *Plural) doInstallOperator(url, token, values string) error {
139144
}
140145
}
141146
vals = algorithms.Merge(vals, globalVals)
142-
err = console.InstallAgent(url, token, console.OperatorNamespace, vals)
147+
err = console.InstallAgent(url, token, console.OperatorNamespace, version, vals)
143148
if err == nil {
144149
utils.Success("deployment operator installed successfully\n")
145150
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ require (
5555
github.com/packethost/packngo v0.29.0
5656
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
5757
github.com/pluralsh/cluster-api-migration v0.2.15
58-
github.com/pluralsh/console-client-go v0.1.17
58+
github.com/pluralsh/console-client-go v0.5.3
5959
github.com/pluralsh/gqlclient v1.11.0
6060
github.com/pluralsh/plural-operator v0.5.5
6161
github.com/pluralsh/polly v0.1.7

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,8 @@ github.com/pluralsh/cluster-api-migration v0.2.15 h1:TIfusD+wnhZTGmwNfIlKlKJOT2d
14261426
github.com/pluralsh/cluster-api-migration v0.2.15/go.mod h1:J6lEvC/70KouikX16mE331cxc3y3sBwtmfHGwZqu06w=
14271427
github.com/pluralsh/console-client-go v0.1.17 h1:QMtnWdRvV13/sND/CFjFBUR8nyg3JJgwXReSyM6bK7A=
14281428
github.com/pluralsh/console-client-go v0.1.17/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
1429+
github.com/pluralsh/console-client-go v0.5.3 h1:RB4XtKlvh8+BM5o1o0h+W6zHculBGbL6q5lI/yRnqJE=
1430+
github.com/pluralsh/console-client-go v0.5.3/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
14291431
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
14301432
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
14311433
github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA=

pkg/console/agent.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
OperatorNamespace = "plrl-deploy-operator"
2121
)
2222

23-
func InstallAgent(url, token, namespace string, values map[string]interface{}) error {
23+
func InstallAgent(url, token, namespace, version string, values map[string]interface{}) error {
2424
settings := cli.New()
2525
vals := map[string]interface{}{
2626
"secrets": map[string]string{
@@ -39,6 +39,9 @@ func InstallAgent(url, token, namespace string, values map[string]interface{}) e
3939
return err
4040
}
4141

42+
newInstallAction := action.NewInstall(helmConfig)
43+
newInstallAction.ChartPathOptions.Version = version
44+
4245
cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings)
4346
if err != nil {
4447
return err

0 commit comments

Comments
 (0)