Skip to content

Commit

Permalink
export vars (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm authored Dec 4, 2023
1 parent 23f72ea commit 6bfc028
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
9 changes: 4 additions & 5 deletions cmd/plural/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func init() {
}

const (
operatorNamespace = "plrl-deploy-operator"
OperatorNamespace = "plrl-deploy-operator"
)

var consoleToken string
Expand Down Expand Up @@ -92,20 +92,19 @@ func (p *Plural) handleUninstallOperator(_ *cli.Context) error {
if err != nil {
return err
}
return console.UninstallAgent(operatorNamespace)
return console.UninstallAgent(OperatorNamespace)
}

func (p *Plural) doInstallOperator(url, token string) error {
err := p.InitKube()
if err != nil {
return err
}
err = p.Kube.CreateNamespace(operatorNamespace)
err = p.Kube.CreateNamespace(OperatorNamespace)
if err != nil && !apierrors.IsAlreadyExists(err) {
return err
}

err = console.InstallAgent(url, token, operatorNamespace)
err = console.InstallAgent(url, token, OperatorNamespace)
if err == nil {
utils.Success("deployment operator installed successfully\n")
}
Expand Down
17 changes: 9 additions & 8 deletions pkg/console/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
)

const (
releaseName = "deploy-operator"
repoUrl = "https://pluralsh.github.io/deployment-operator"
ChartName = "deployment-operator"
ReleaseName = "deploy-operator"
RepoUrl = "https://pluralsh.github.io/deployment-operator"
)

func InstallAgent(url, token, namespace string) error {
Expand All @@ -26,7 +27,7 @@ func InstallAgent(url, token, namespace string) error {
"consoleUrl": url,
}

if err := helm.AddRepo(releaseName, repoUrl); err != nil {
if err := helm.AddRepo(ReleaseName, RepoUrl); err != nil {
return err
}

Expand All @@ -35,7 +36,7 @@ func InstallAgent(url, token, namespace string) error {
return err
}

cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", releaseName, "deployment-operator"), settings)
cp, err := action.NewInstall(helmConfig).ChartPathOptions.LocateChart(fmt.Sprintf("%s/%s", ReleaseName, ChartName), settings)
if err != nil {
return err
}
Expand All @@ -48,11 +49,11 @@ func InstallAgent(url, token, namespace string) error {
histClient := action.NewHistory(helmConfig)
histClient.Max = 5

if _, err = histClient.Run(releaseName); errors.Is(err, driver.ErrReleaseNotFound) {
if _, err = histClient.Run(ReleaseName); errors.Is(err, driver.ErrReleaseNotFound) {
fmt.Println("installing deployment operator...")
instClient := action.NewInstall(helmConfig)
instClient.Namespace = namespace
instClient.ReleaseName = releaseName
instClient.ReleaseName = ReleaseName
instClient.Timeout = time.Minute * 5
_, err = instClient.Run(chart, vals)
if err != nil {
Expand All @@ -64,10 +65,10 @@ func InstallAgent(url, token, namespace string) error {
client := action.NewUpgrade(helmConfig)
client.Namespace = namespace
client.Timeout = time.Minute * 5
_, err = client.Run(releaseName, chart, vals)
_, err = client.Run(ReleaseName, chart, vals)
return err
}

func UninstallAgent(namespace string) error {
return helm.Uninstall(releaseName, namespace)
return helm.Uninstall(ReleaseName, namespace)
}

0 comments on commit 6bfc028

Please sign in to comment.