fix: apply export-values and import-values to --values, --secret-values, --set and service values
Merged
IL
13d ago+1094+1094+0123456789012345678901234567890123456789-169-169-012345678901234567890123456789
Summary
Make export-values and import-values take effect for values from --values, --secret-values, --set* and service values, not only for chart files.
What
- Export-values export plain values, maps and nulls from every user values layer. Before, a plain value such as
--set g.repo=xwas not exported, because the parent was read as a table. - Import-values (map and
exports.*string forms) import the child's values from every user values layer. - Nested parents, multi-level chains (parent → child → grandchild) and aliased subcharts work. Aliases are resolved before user values are exported.
- Mappings apply within each layer, ordered
--values<--secret-values<--set*< service values. Within a layer an exported value overrides the child key and an imported value loses to the parent key. Across layers the higher layer wins. --set-json key={...}still replaces a map from lower layers, including maps that lower layers got from export-values or import-values.- For v2 charts,
--secret-valuesand service values are no longer folded into chart values during dependency processing, because they are now user layers. Otherwise they would act as chart defaults for export-values and import-values, and--set-jsoncould not replace them. They are still folded in when the chart values are invalid without them (for example,sub: nullinvalues.yaml). - The stored release config holds
--values<--secret-values<--set*(decrypted) plus whatexport-valuesadds from them under the rules above. It does not hold service values, the chart's ownsecret-values.yaml, or whatimport-valuesadds. --set*values are applied more than once (to find the paths they set and the maps they replace), so--set-filecontents are now cached and each file is read once.- BREAKING-ish behaviour changes:
- An exported parent value now overrides the child key from the same or a lower layer. For example,
--set g.repo=a --set sub.image.repository=brendersa, and service values exported tosub.image.repositoryoverride--set sub.image.repository. Before, the user's child key won. - A
nullparent value in a layer now deletes the exported child key. - Dependency
condition:values now see plain values exported from user values. Before, only maps were exported. - Imported values now follow user values:
--set sub.out.k=xchanges the parent's importedk. - The stored release config follows the new export rules, so a release whose config holds exported values may be redeployed once after updating.
- For v2 charts with dependencies, the values of the chart stored in the release no longer include
--secret-valuesand service values, except in the fallback case above.
- An exported parent value now overrides the child key from the same or a lower layer. For example,
Go API
values.Options.MergeSetValuestakes a new last argumentMergeSetValuesOptions. ItsSetFilesCachefield caches--set-filecontents across calls.chartv2util.ExportUserValuesnow takes one layer of values and returns the result instead of modifying a pointer. Addedchartv2util.ImportUserValues.
Why
export-values and import-values were applied to chart files only (plus maps from user values), so overriding a parent key from the command line or from werf had no effect on subcharts, and overriding a child key did not reach the importing parent.