diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 162bad3c94..13795a6394 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -258,7 +258,7 @@ func (h *Helm) GenerateChart(manifest types.ZarfManifest) error { h.ChartOverride = tmpChart // We don't have any values because we do not expose them in the zarf.yaml currently. - h.ValueOverride = map[string]any{} + h.ValuesOverrides = map[string]any{} spinner.Success() @@ -426,7 +426,7 @@ func (h *Helm) loadChartData() (*chart.Chart, chartutil.Values, error) { err error ) - if h.ChartOverride == nil || h.ValueOverride == nil { + if h.ChartOverride == nil { // If there is no override, get the chart and values info. loadedChart, err = h.loadChartFromTarball() if err != nil { @@ -440,7 +440,7 @@ func (h *Helm) loadChartData() (*chart.Chart, chartutil.Values, error) { } else { // Otherwise, use the overrides instead. loadedChart = h.ChartOverride - chartValues = h.ValueOverride + chartValues = h.ValuesOverrides } return loadedChart, chartValues, nil diff --git a/src/internal/packager/helm/common.go b/src/internal/packager/helm/common.go index 34e9047702..74b6d476cf 100644 --- a/src/internal/packager/helm/common.go +++ b/src/internal/packager/helm/common.go @@ -21,7 +21,7 @@ type Helm struct { ReleaseName string ChartLoadOverride string ChartOverride *chart.Chart - ValueOverride map[string]any + ValuesOverrides map[string]any Component types.ZarfComponent Cluster *cluster.Cluster Cfg *types.PackagerConfig diff --git a/src/internal/packager/helm/utils.go b/src/internal/packager/helm/utils.go index c19eb492c5..f06aa54222 100644 --- a/src/internal/packager/helm/utils.go +++ b/src/internal/packager/helm/utils.go @@ -11,6 +11,7 @@ import ( "github.com/defenseunicorns/zarf/src/pkg/layout" "github.com/defenseunicorns/zarf/src/pkg/message" + "github.com/defenseunicorns/zarf/src/pkg/utils/helpers" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" @@ -61,7 +62,12 @@ func (h *Helm) parseChartValues() (chartutil.Values, error) { } providers := getter.Providers{httpProvider} - return valueOpts.MergeValues(providers) + chartValues, err := valueOpts.MergeValues(providers) + if err != nil { + return chartValues, err + } + + return helpers.MergeMapRecursive(chartValues, h.ValuesOverrides), nil } func (h *Helm) createActionConfig(namespace string, spinner *message.Spinner) error { diff --git a/src/pkg/packager/deploy.go b/src/pkg/packager/deploy.go index b48dad3069..2a06590ac1 100644 --- a/src/pkg/packager/deploy.go +++ b/src/pkg/packager/deploy.go @@ -526,6 +526,13 @@ func (p *Packager) installChartAndManifests(componentPath *layout.ComponentPaths Cluster: p.cluster, } + // TODO (@WSTARR): Currently this logic is library-only and is untested while it is in an experimental state - it may eventually get added as shorthand in Zarf Variables though + if componentChartValuesOverrides, ok := p.cfg.DeployOpts.ValuesOverridesMap[component.Name]; ok { + if chartValuesOverrides, ok := componentChartValuesOverrides[chart.Name]; ok { + helmCfg.ValuesOverrides = chartValuesOverrides + } + } + addedConnectStrings, installedChartName, err := helmCfg.InstallOrUpgradeChart() if err != nil { return installedCharts, err diff --git a/src/types/runtime.go b/src/types/runtime.go index a812043a68..b9546c1658 100644 --- a/src/types/runtime.go +++ b/src/types/runtime.go @@ -49,6 +49,9 @@ type ZarfFindImagesOptions struct { type ZarfDeployOptions struct { AdoptExistingResources bool `json:"adoptExistingResources" jsonschema:"description=Whether to adopt any pre-existing K8s resources into the Helm charts managed by Zarf"` SkipWebhooks bool `json:"componentWebhooks" jsonschema:"description=Skip waiting for external webhooks to execute as each package component is deployed"` + + // TODO (@WSTARR): This is a library only addition to Zarf and should be refactored in the future (potentially to utilize component composability). As is it should NOT be exposed directly on the CLI + ValuesOverridesMap map[string]map[string]map[string]interface{} `json:"valuesOverridesMap" jsonschema:"description=[Library Only] A map of component names to chart names containing Helm Chart values to override values on deploy"` } // ZarfMirrorOptions tracks the user-defined preferences during a package mirror.