From 546be76f55ed7a85028a905ca196fe418084c22d Mon Sep 17 00:00:00 2001
From: Max Jonas Werner <mail@makk.es>
Date: Thu, 16 Sep 2021 15:54:58 +0200
Subject: [PATCH] fix: don't set 'Install' field by default in 'create hr'

This fixes the case where you create a HelmRelease with `--export` and
the `install: {}` field being there, adding no value to the manifest.

Signed-off-by: Max Jonas Werner <mail@makk.es>
---
 cmd/flux/create_helmrelease.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmd/flux/create_helmrelease.go b/cmd/flux/create_helmrelease.go
index f3373696..6b569d89 100644
--- a/cmd/flux/create_helmrelease.go
+++ b/cmd/flux/create_helmrelease.go
@@ -182,13 +182,16 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
 					},
 				},
 			},
-			Install: &helmv2.Install{
-				CreateNamespace: helmReleaseArgs.createNamespace,
-			},
 			Suspend: false,
 		},
 	}
 
+	if helmReleaseArgs.createNamespace {
+		helmRelease.Spec.Install = &helmv2.Install{
+			CreateNamespace: helmReleaseArgs.createNamespace,
+		}
+	}
+
 	if helmReleaseArgs.saName != "" {
 		helmRelease.Spec.ServiceAccountName = helmReleaseArgs.saName
 	}
-- 
GitLab