diff --git a/internal/controller/deployment_controller.go b/internal/controller/deployment_controller.go index 28d2c91aa..da3c1c13a 100644 --- a/internal/controller/deployment_controller.go +++ b/internal/controller/deployment_controller.go @@ -196,7 +196,7 @@ func (r *DeploymentReconciler) Update(ctx context.Context, l logr.Logger, deploy }) if !deployment.Spec.DryRun { - ownerRef := metav1.OwnerReference{ + ownerRef := &metav1.OwnerReference{ APIVersion: hmc.GroupVersion.String(), Kind: hmc.DeploymentKind, Name: deployment.Name, diff --git a/internal/controller/management_controller.go b/internal/controller/management_controller.go index da1a8a26c..b7a6048b8 100644 --- a/internal/controller/management_controller.go +++ b/internal/controller/management_controller.go @@ -64,7 +64,7 @@ func (r *ManagementReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, r.Client.Update(ctx, management) } - ownerRef := metav1.OwnerReference{ + ownerRef := &metav1.OwnerReference{ APIVersion: hmc.GroupVersion.String(), Kind: hmc.ManagementKind, Name: management.Name, diff --git a/internal/controller/release_controller.go b/internal/controller/release_controller.go index 3057f9d3c..9344f62a8 100644 --- a/internal/controller/release_controller.go +++ b/internal/controller/release_controller.go @@ -200,7 +200,7 @@ func (p *Poller) reconcileHMCTemplates(ctx context.Context) error { Name: helmChart.Name, Namespace: helmChart.Namespace, } - _, operation, err = helm.ReconcileHelmRelease(ctx, p.Client, hmcTemplatesReleaseName, hmc.TemplatesNamespace, nil, metav1.OwnerReference{}, chartRef, defaultReconcileInterval, nil) + _, operation, err = helm.ReconcileHelmRelease(ctx, p.Client, hmcTemplatesReleaseName, hmc.TemplatesNamespace, nil, nil, chartRef, defaultReconcileInterval, nil) if err != nil { return err } diff --git a/internal/helm/release.go b/internal/helm/release.go index 85275bb0a..4a2c57724 100644 --- a/internal/helm/release.go +++ b/internal/helm/release.go @@ -34,7 +34,7 @@ func ReconcileHelmRelease( name string, namespace string, values *apiextensionsv1.JSON, - ownerReference metav1.OwnerReference, + ownerReference *metav1.OwnerReference, chartRef *hcv2.CrossNamespaceSourceReference, reconcileInterval time.Duration, dependsOn []meta.NamespacedObjectReference, @@ -51,7 +51,9 @@ func ReconcileHelmRelease( helmRelease.Labels = make(map[string]string) } helmRelease.Labels[hmc.HMCManagedLabelKey] = "true" - helmRelease.OwnerReferences = []metav1.OwnerReference{ownerReference} + if ownerReference != nil { + helmRelease.OwnerReferences = []metav1.OwnerReference{*ownerReference} + } helmRelease.Spec = hcv2.HelmReleaseSpec{ ChartRef: chartRef, Interval: metav1.Duration{Duration: reconcileInterval},