From 370be06e946f9d706ade948bdac191f1678b0258 Mon Sep 17 00:00:00 2001 From: Robin Breathe Date: Wed, 17 Apr 2024 16:36:07 +0200 Subject: [PATCH] feat(HelmChartTemplateSpec): optionally ignore missing valuesFiles Signed-off-by: Robin Breathe --- api/v2beta1/helmrelease_types.go | 4 ++++ api/v2beta2/helmrelease_types.go | 4 ++++ .../helm.toolkit.fluxcd.io_helmreleases.yaml | 8 +++++++ docs/api/v2beta1/helm.md | 12 ++++++++++ docs/api/v2beta2/helm.md | 24 +++++++++++++++++++ docs/spec/v2beta1/helmreleases.md | 4 ++++ internal/reconcile/helmchart_template.go | 9 +++---- 7 files changed, 61 insertions(+), 4 deletions(-) diff --git a/api/v2beta1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go index 697e4668b..24f010d4a 100644 --- a/api/v2beta1/helmrelease_types.go +++ b/api/v2beta1/helmrelease_types.go @@ -321,6 +321,10 @@ type HelmChartTemplateSpec struct { // +deprecated ValuesFile string `json:"valuesFile,omitempty"` + // IgnoreMissingValuesFiles controls whether to silently ignore missing values files rather than failing. + // +optional + IgnoreMissingValuesFiles bool `json:"ignoreMissingValuesFiles,omitempty"` + // Verify contains the secret name containing the trusted public keys // used to verify the signature and specifies which provider to use to check // whether OCI image is authentic. diff --git a/api/v2beta2/helmrelease_types.go b/api/v2beta2/helmrelease_types.go index 9db38102f..05c88b8fc 100644 --- a/api/v2beta2/helmrelease_types.go +++ b/api/v2beta2/helmrelease_types.go @@ -376,6 +376,10 @@ type HelmChartTemplateSpec struct { // +deprecated ValuesFile string `json:"valuesFile,omitempty"` + // IgnoreMissingValuesFiles controls whether to silently ignore missing values files rather than failing. + // +optional + IgnoreMissingValuesFiles bool `json:"ignoreMissingValuesFiles,omitempty"` + // Verify contains the secret name containing the trusted public keys // used to verify the signature and specifies which provider to use to check // whether OCI image is authentic. diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index e38f8922e..de7bcfe4d 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -88,6 +88,10 @@ spec: description: The name or path the Helm chart is available at in the SourceRef. type: string + ignoreMissingValuesFiles: + description: IgnoreMissingValuesFiles controls whether to + silently ignore missing values files rather than failing. + type: boolean interval: description: |- Interval at which to check the v1beta2.Source for updates. Defaults to @@ -1320,6 +1324,10 @@ spec: maxLength: 2048 minLength: 1 type: string + ignoreMissingValuesFiles: + description: IgnoreMissingValuesFiles controls whether to + silently ignore missing values files rather than failing. + type: boolean interval: description: |- Interval at which to check the v1.Source for updates. Defaults to diff --git a/docs/api/v2beta1/helm.md b/docs/api/v2beta1/helm.md index 4076569d8..1153dbe20 100644 --- a/docs/api/v2beta1/helm.md +++ b/docs/api/v2beta1/helm.md @@ -604,6 +604,18 @@ ValuesFiles items. Ignored when omitted.

+ignoreMissingValuesFiles
+ +bool + + + +(Optional) +

Whether to silently ignore missing values files rather than failing.

+ + + + verify
diff --git a/docs/api/v2beta2/helm.md b/docs/api/v2beta2/helm.md index 020813053..a7a456923 100644 --- a/docs/api/v2beta2/helm.md +++ b/docs/api/v2beta2/helm.md @@ -807,6 +807,18 @@ ValuesFiles items. Ignored when omitted.

+ignoreMissingValuesFiles
+ +bool + + + +(Optional) +

Whether to silently ignore missing values files rather than failing.

+ + + + verify
@@ -999,6 +1011,18 @@ ValuesFiles items. Ignored when omitted.

+ignoreMissingValuesFiles
+ +bool + + + +(Optional) +

Whether to silently ignore missing values files rather than failing.

+ + + + verify
diff --git a/docs/spec/v2beta1/helmreleases.md b/docs/spec/v2beta1/helmreleases.md index 556291d2f..e9ab90dc3 100644 --- a/docs/spec/v2beta1/helmreleases.md +++ b/docs/spec/v2beta1/helmreleases.md @@ -215,6 +215,10 @@ type HelmChartTemplateSpec struct { // +optional // +deprecated ValuesFile string `json:"valuesFile,omitempty"` + + // IgnoreMissingValuesFiles controls whether to silently ignore missing values files rather than failing. + // +optional + IgnoreMissingValuesFiles bool `json:"ignoreMissingValuesFiles,omitempty"` } // Install holds the configuration for Helm install actions performed for this diff --git a/internal/reconcile/helmchart_template.go b/internal/reconcile/helmchart_template.go index 4769c21dd..c96cad3e8 100644 --- a/internal/reconcile/helmchart_template.go +++ b/internal/reconcile/helmchart_template.go @@ -226,10 +226,11 @@ func buildHelmChartFromTemplate(obj *v2.HelmRelease) *sourcev1.HelmChart { Name: template.Spec.SourceRef.Name, Kind: template.Spec.SourceRef.Kind, }, - Interval: template.GetInterval(obj.Spec.Interval), - ReconcileStrategy: template.Spec.ReconcileStrategy, - ValuesFiles: template.Spec.ValuesFiles, - ValuesFile: template.Spec.ValuesFile, + Interval: template.GetInterval(obj.Spec.Interval), + ReconcileStrategy: template.Spec.ReconcileStrategy, + ValuesFiles: template.Spec.ValuesFiles, + ValuesFile: template.Spec.ValuesFile, + IgnoreMissingValuesFiles: template.Spec.IgnoreMissingValuesFiles, }, } if verifyTpl := template.Spec.Verify; verifyTpl != nil {