Skip to content

Commit 73a0528

Browse files
authored
fix: expose --create-namespace for argo addon; set namespace during helm uninstall (#510)
Signed-off-by: Artur Shad Nik <[email protected]>
1 parent a3d694e commit 73a0528

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

pkg/cmd/install/hubaddon/exec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (o *Options) createNamespace() error {
169169
func (o *Options) runWithHelmClient(addon string) error {
170170
if addon == argocdAddonName {
171171
o.Helm.WithNamespace(argocdNamespace)
172+
o.Helm.WithCreateNamespace(o.values.CreateNamespace)
172173
if err := o.Helm.PrepareChart(repoName, url); err != nil {
173174
return err
174175
}

pkg/cmd/uninstall/hubaddon/exec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
var (
2121
argocdAddonName = "argocd"
22+
argocdNamespace = "argocd"
2223
argocdReleaseName = "argocd-pull-integration"
2324
policyFrameworkAddonName = "governance-policy-framework"
2425
)
@@ -148,6 +149,7 @@ func (o *Options) runWithHelmClient(addon string) error {
148149
}
149150

150151
if addon == argocdAddonName {
152+
o.Helm.WithNamespace(argocdNamespace)
151153
if err := o.Helm.UninstallRelease(argocdReleaseName); err != nil {
152154
return err
153155
}

pkg/helpers/helm/helm.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ import (
2929
const HelmFlagSetAnnotation = "HelmSet"
3030

3131
type Helm struct {
32-
settings *cli.EnvSettings
33-
values *values.Options
32+
settings *cli.EnvSettings
33+
values *values.Options
34+
createNamespace bool
3435
}
3536

3637
func NewHelm() *Helm {
@@ -48,6 +49,10 @@ func (h *Helm) WithNamespace(ns string) {
4849
h.settings.SetNamespace(ns)
4950
}
5051

52+
func (h *Helm) WithCreateNamespace(createNS bool) {
53+
h.createNamespace = createNS
54+
}
55+
5156
func (h *Helm) AddFlags(fs *pflag.FlagSet) {
5257
fs.StringArrayVarP(&h.values.ValueFiles, "values", "f", []string{}, "specify values in a YAML file")
5358
fs.StringArrayVar(&h.values.Values, "set-string", []string{}, "set string for chart")
@@ -157,6 +162,7 @@ func (h *Helm) InstallChart(name, repo, chart string) {
157162
log.Fatal(err)
158163
}
159164
client := action.NewInstall(actionConfig)
165+
client.CreateNamespace = h.createNamespace
160166

161167
if client.Version == "" && client.Devel {
162168
client.Version = ">0.0.0-0"

0 commit comments

Comments
 (0)