From 0d0285ad0942d13700fdd4a4116218cd2e2446e8 Mon Sep 17 00:00:00 2001 From: Soule BA Date: Tue, 7 May 2024 11:16:04 +0200 Subject: [PATCH] Enable reconciling HelmReleases with ChartRef If implemented HR with ChartRef can be reconciled with `--with-source`set. Signed-off-by: Soule BA --- cmd/flux/reconcile_helmrelease.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/flux/reconcile_helmrelease.go b/cmd/flux/reconcile_helmrelease.go index 25f77464..02eda046 100644 --- a/cmd/flux/reconcile_helmrelease.go +++ b/cmd/flux/reconcile_helmrelease.go @@ -74,13 +74,25 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName force: true, } - ns := obj.Spec.Chart.Spec.SourceRef.Namespace + var ( + name string + ns string + ) + switch { + case obj.Spec.Chart != &helmv2.HelmChart{}: + ns = obj.Spec.Chart.Spec.SourceRef.Namespace + name = fmt.Sprintf("%s-%s", obj.Namespace, obj.Name) + case obj.Spec.ChartRef != nil: + ns = obj.Spec.ChartRef.Namespace + name = obj.Spec.ChartRef.Name + } + if ns == "" { ns = obj.Namespace } return cmd, types.NamespacedName{ - Name: fmt.Sprintf("%s-%s", obj.Namespace, obj.Name), + Name: name, Namespace: ns, } }