Skip to content

Commit

Permalink
Make the createRelease value actually not install the release. Also, …
Browse files Browse the repository at this point in the history
…change the chart version code to match up with what exists in the helm repo
  • Loading branch information
kylewuolle committed Oct 8, 2024
1 parent 6b1b22c commit 929a4ca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/dev/hmc_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ image:
controller:
defaultRegistryURL: oci://hmc-local-registry:5000/charts
insecureRegistry: true
createRelease: false
createRelease: true
createTemplates: false
14 changes: 9 additions & 5 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ 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)
}
mgmtObj.Spec.Release, err = r.getCurrentReleaseName(ctx)
if err != nil {
return err

if r.CreateRelease {
mgmtObj.Spec.Release, err = r.getCurrentReleaseName(ctx)
if err != nil {
return err
}
}

if err := mgmtObj.Spec.SetProvidersDefaults(); err != nil {
return err
}
Expand Down Expand Up @@ -157,7 +161,7 @@ func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl.
l.Info("Templates creation is disabled")
return nil
}
if initialReconcile(req) && !r.CreateRelease {
if !r.CreateRelease || initialReconcile(req) {
l.Info("Initial creation of HMC Release is skipped")
return nil
}
Expand Down Expand Up @@ -206,7 +210,7 @@ func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl.
helmChart.Labels[hmc.HMCManagedLabelKey] = hmc.HMCManagedLabelValue
helmChart.Spec = sourcev1.HelmChartSpec{
Chart: r.HMCTemplatesChartName,
Version: version,
Version: utils.ChartVersionFromVersion(version),
SourceRef: sourcev1.LocalHelmChartSourceReference{
Kind: sourcev1.HelmRepositoryKind,
Name: defaultRepoName,
Expand Down
9 changes: 9 additions & 0 deletions internal/utils/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ 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"
}

0 comments on commit 929a4ca

Please sign in to comment.