From be198070892a54281b23fe56c2073f193708e304 Mon Sep 17 00:00:00 2001 From: Slava Lysunkin Date: Tue, 8 Oct 2024 20:54:45 -0500 Subject: [PATCH] Revert "Make the createRelease value actually not install the release. Also, change the chart version code to match up with what exists in the helm repo" This reverts commit 929a4ca9bed2da7d4b9827fb7e0dc5231e6d856b. --- config/dev/hmc_values.yaml | 2 +- internal/controller/release_controller.go | 14 +++++--------- internal/utils/release.go | 9 --------- 3 files changed, 6 insertions(+), 19 deletions(-) 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" }