optimizes flux helmReleases with a helper. Fixes bugs detected and adds unit tests for validation
General MR
Summary
Added 2 shared helpers to chart/templates/_helpers.tpl:
-
bigbang.helmRelease.chartSpec— Generates thespec.chart.specblock handling git vs helmRepo source selection with cosign verification. Acceptsname,package(values object), androot(context). -
bigbang.helmRelease.valuesFrom— Generates the standard 3-secretvaluesFromblock (common/defaults/overlays). Acceptsname(secret suffix) androot(context).
Files updated: 42 helmrelease.yaml files
- 37 standard packages — chart spec + valuesFrom replaced
-
5
$pkg-variable packages (kyverno-policies, kyverno-reporter, harbor, thanos, fortify) — chart spec + valuesFrom replaced - 1 istio-gateway — chart spec only (valuesFrom has unique per-gateway naming)
Files left untouched: 3 files
-
package/helmrelease.yaml— loop-based dynamic HelmRelease generation -
wrapper/helmrelease.yaml— loop-based wrapper chart generation -
istio-gateway/helmrelease.yamlvaluesFrom — unique per-gateway secret naming
Impact
- ~1,200 lines of redundant template code removed (net reduction)
-
Bug fix: nexus-repository-manager had a copy-paste bug referencing
.Values.neuvector.helmRepo.repoNamein its cosign verify block instead of$nexusValues.helmRepo.repoName. The shared helper now correctly uses the passed package values. - No immutable field changes: All rendered HelmRelease resources are byte-for-byte identical (verified via PyYAML comparison of 17 rendered HelmReleases)
- All 33 test suites pass (119 tests)
- No Flux recreations: Since the rendered output is identical, existing deployments will see no changes to immutable fields
5 additional bugs detected and fixed:
-
grafana/helmrelease.yaml— Copy-paste bug: flux settings variable was named$fluxSettingsMonitoringinstead of$fluxSettingsGrafana. While the variable value merged.Values.grafana.fluxcorrectly, the misleading name would cause confusion. Both the variable declaration and usage were renamed. -
backstage/helmrelease.yaml— The kyverno dependency was hardcoded inside thegrafana.enabledblock with no check for.Values.kyverno.enabled. If grafana was enabled but kyverno was not, the HelmRelease would block forever waiting for a non-existent kyverno release. Fixed by giving kyverno its own conditional guard and adding it to the outerorcondition. -
fluentbit/helmrelease.yaml—.Values.loki.enabledwas missing from the outerorcondition for thedependsOnblock. If only loki was enabled (and none of EK, gatekeeper, istio, kyverno, monitoring), the entiredependsOnblock would not render, silently dropping the loki dependency. Addedloki.enabledto the outer condition. -
gitlab-runner/helmrelease.yaml— Same pattern:.Values.kyverno.enabledwas missing from the outerorcondition. If only kyverno was enabled, the kyverno dependency would be silently dropped. Addedkyverno.enabledto the outer condition. -
sonarqube/helmrelease.yaml— Orphaned emptyvalues:key (leftover from a refactor). Removed it.
48 new tests in chart/unittests/packages/helmrelease/helmrelease_test.yaml covering:
- Enable/disable rendering (core + addon packages)
- Chart spec helper — git and helmRepo source types
- ValuesFrom helper — 3-secret pattern, correct secret naming
- Labels, metadata, and checksum annotations
- targetNamespace correctness (monitoring, logging, gatekeeper-system, istio-system, kube-system)
- Special cases (gatekeeper persistentClient, loki releaseName, EK name mismatch)
- Bug regression tests for all 5 fixes (grafana flux var, backstage kyverno, fluentbit loki, gitlab-runner kyverno, sonarqube values)
- DependsOn correctness (unconditional deps, conditional istio deps, no-dep packages)
- Compound enable conditions (eck-operator, kyverno, minio-operator)
- Nexus sourceRef correctness (validates the earlier shared helper bug fix)
- Flux settings merge behavior
- Prerequisite fail checks (istiod→istioCRDs, istio-cni→istiod)
- Mattermost-operator legacy values merge
Linked Issue
Closes #3152 (closed)
Upgrade Notices
N/A