sylva-units: avoid producing a 'spec.kubeConfig: null' for Kustomizations and HelmReleases

Context

In workload-cluster.values.yaml we need to adapt the kubeConfig to which Kustomization and HelmRelease point to, to account for the fact that most Kustomizations need to target the workload cluster, but that some of them do not. For this we combine the global unit_kustomization_spec_default and unit_helmrelease_kustomization_spec_default, unit_helmrelease_spec_default settings, with per-unit kustomization_spec and helmrelease_spec.

Problem

When a unit using helmrelease_spec need to reset the kubeConfig set in unit_helmrelease_spec_default, the only way is to set it to null, but this results in errors like:

      HelmRelease/workload-cluster/cluster dry-run failed, reason: Invalid, error: HelmRelease.helm.toolkit.fluxcd.io "cluster" is invalid: spec.kubeConfig: Invalid value: "null": spec.kubeConfig in body must be of type object: "null"

Solution

This MR adapts the templating code to not produce any spec.kubeConfig field in the produced HelmRelease when the merge of helmrelease_spec and unit_helmrelease_spec_default resulted in having this field set to null.

This MR does the same processing for Kustomizations, because this is just cleaner.

References

This is MR is a pre-requisite for !455 (merged) and !472 (merged).

/cc @baburciu

Edited by Thomas Morin

Merge request reports

Loading