diff --git a/config/dev/hmc_values.yaml b/config/dev/hmc_values.yaml index ea8e4958b..68bdf3b10 100644 --- a/config/dev/hmc_values.yaml +++ b/config/dev/hmc_values.yaml @@ -4,5 +4,5 @@ image: controller: defaultRegistryURL: oci://hmc-local-registry:5000/charts insecureRegistry: true - createRelease: true + createRelease: false createTemplates: false diff --git a/internal/controller/release_controller.go b/internal/controller/release_controller.go index 7d32f495b..8736e148d 100644 --- a/internal/controller/release_controller.go +++ b/internal/controller/release_controller.go @@ -106,14 +106,10 @@ func (r *ReleaseReconciler) ensureManagement(ctx context.Context) error { if !apierrors.IsNotFound(err) { return fmt.Errorf("failed to get %s Management object: %w", hmc.TemplateManagementName, err) } - - if r.CreateRelease { - mgmtObj.Spec.Release, err = r.getCurrentReleaseName(ctx) - if err != nil { - return err - } + mgmtObj.Spec.Release, err = r.getCurrentReleaseName(ctx) + if err != nil { + return err } - if err := mgmtObj.Spec.SetProvidersDefaults(); err != nil { return err } @@ -161,7 +157,7 @@ func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl. l.Info("Templates creation is disabled") return nil } - if !r.CreateRelease || initialReconcile(req) { + if initialReconcile(req) && !r.CreateRelease { l.Info("Initial creation of HMC Release is skipped") return nil } @@ -210,7 +206,7 @@ func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl. helmChart.Labels[hmc.HMCManagedLabelKey] = hmc.HMCManagedLabelValue helmChart.Spec = sourcev1.HelmChartSpec{ Chart: r.HMCTemplatesChartName, - Version: utils.ChartVersionFromVersion(version), + Version: version, SourceRef: sourcev1.LocalHelmChartSourceReference{ Kind: sourcev1.HelmRepositoryKind, Name: defaultRepoName, diff --git a/internal/utils/release.go b/internal/utils/release.go index 8162dbea0..3acc85ce0 100644 --- a/internal/utils/release.go +++ b/internal/utils/release.go @@ -20,15 +20,6 @@ func ReleaseNameFromVersion(version string) string { return "hmc-" + strings.ReplaceAll(strings.TrimPrefix(version, "v"), ".", "-") } -func ChartVersionFromVersion(version string) string { - index := strings.Index(version, "-") - cut := strings.TrimPrefix(version, "v") - if index >= 1 { - cut = cut[:index-1] - } - return cut -} - func TemplatesChartFromReleaseName(releaseName string) string { return releaseName + "-tpl" }