diff --git a/api/v1beta2/helmchart_types.go b/api/v1beta2/helmchart_types.go index 0603ee5b..eb46fefc 100644 --- a/api/v1beta2/helmchart_types.go +++ b/api/v1beta2/helmchart_types.go @@ -147,6 +147,10 @@ type HelmChartStatus struct { // +optional ObservedChartName string `json:"observedChartName,omitempty"` + // ObservedValuesFiles are the last observed value files. + // +optional + ObservedValuesFiles []string `json:"observedValuesFiles,omitempty"` + // Conditions holds the conditions for the HelmChart. // +optional Conditions []metav1.Condition `json:"conditions,omitempty"` diff --git a/internal/controller/helmchart_controller.go b/internal/controller/helmchart_controller.go index 3e71c1db..a0cf8e15 100644 --- a/internal/controller/helmchart_controller.go +++ b/internal/controller/helmchart_controller.go @@ -666,6 +666,7 @@ func (r *HelmChartReconciler) buildFromHelmRepository(ctx context.Context, obj * cb := chart.NewRemoteBuilder(chartRepo) opts := chart.BuildOptions{ ValuesFiles: obj.GetValuesFiles(), + ObservedValuesFiles: obj.Status.ObservedValuesFiles, IgnoreMissingValuesFiles: obj.Spec.IgnoreMissingValuesFiles, Force: obj.Generation != obj.Status.ObservedGeneration, // The remote builder will not attempt to download the chart if @@ -762,6 +763,7 @@ func (r *HelmChartReconciler) buildFromTarballArtifact(ctx context.Context, obj // Configure builder options, including any previously cached chart opts := chart.BuildOptions{ ValuesFiles: obj.GetValuesFiles(), + ObservedValuesFiles: obj.Status.ObservedValuesFiles, IgnoreMissingValuesFiles: obj.Spec.IgnoreMissingValuesFiles, Force: obj.Generation != obj.Status.ObservedGeneration, } @@ -886,6 +888,7 @@ func (r *HelmChartReconciler) reconcileArtifact(ctx context.Context, _ *patch.Se // Record it on the object obj.Status.Artifact = artifact.DeepCopy() obj.Status.ObservedChartName = b.Name + obj.Status.ObservedValuesFiles = b.ValuesFiles // Update symlink on a "best effort" basis symURL, err := r.Storage.Symlink(artifact, "latest.tar.gz") diff --git a/internal/helm/chart/builder.go b/internal/helm/chart/builder.go index ba4f74e9..98725d3e 100644 --- a/internal/helm/chart/builder.go +++ b/internal/helm/chart/builder.go @@ -107,6 +107,9 @@ type BuildOptions struct { // ValuesFiles can be set to a list of relative paths, used to compose // and overwrite an alternative default "values.yaml" for the chart. ValuesFiles []string + // ObservedValuesFiles is calculated when the chart is built. If BuildOptions.IgnoreMissingValuesFiles is set, + // this list will contain the values files that were actually found on disk. + ObservedValuesFiles []string // IgnoreMissingValuesFiles controls whether to silently ignore missing values files rather than failing. IgnoreMissingValuesFiles bool // CachedChart can be set to the absolute path of a chart stored on diff --git a/internal/helm/chart/builder_local.go b/internal/helm/chart/builder_local.go index d7fcf516..cee286a3 100644 --- a/internal/helm/chart/builder_local.go +++ b/internal/helm/chart/builder_local.go @@ -120,7 +120,7 @@ func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string, if err = curMeta.Validate(); err == nil { if result.Name == curMeta.Name && result.Version == curMeta.Version { result.Path = opts.CachedChart - result.ValuesFiles = opts.GetValuesFiles() + result.ValuesFiles = opts.ObservedValuesFiles result.Packaged = requiresPackaging return result, nil diff --git a/internal/helm/chart/builder_remote.go b/internal/helm/chart/builder_remote.go index 7a87d01d..222f0a1b 100644 --- a/internal/helm/chart/builder_remote.go +++ b/internal/helm/chart/builder_remote.go @@ -202,7 +202,7 @@ func generateBuildResult(cv *repo.ChartVersion, opts BuildOptions) (*Build, bool if err = curMeta.Validate(); err == nil { if result.Name == curMeta.Name && result.Version == curMeta.Version { result.Path = opts.CachedChart - result.ValuesFiles = opts.GetValuesFiles() + result.ValuesFiles = opts.ObservedValuesFiles result.Packaged = requiresPackaging return result, true, nil }