fix: warn about export-values and import-values paths set in no values
Summary
A typo in the parent: of export-values is reported again, and the false ImportValues missing table warning for tables set only in values files, set values or extra values is gone. Both are now one check after all values layers are processed.
What
- New
ExportAndImportValuesNotFoundWarningsinpkg/helm/pkg/chart/v2/util/dependencies_nelm.go(the upstreamdependencies.gokeeps only the call and the removed warnings), called once fromprocessDependencies(render) and fromProcessDependencies(lint) after all layers are exported, merged and imported.- export-values of enabled dependencies: one warning when the parent path is set in no values layer (before and after export/import), not in the chart values before processing, and not in the values the chart-level pass reads (the declaring chart's values, or its globals merged from the root chart for
global.*). - import-values (map and string forms) of enabled dependencies: one warning when no layer has the child path and the chart-level pass found no map there. A non-map in a user layer keeps its existing
only a map can be importedmessage. - Disabled dependencies (condition/tags) are not checked.
- export-values of enabled dependencies: one warning when the parent path is set in no values layer (before and after export/import), not in the chart values before processing, and not in the values the chart-level pass reads (the declaring chart's values, or its globals merged from the root chart for
- The chart-level
processImportValuesno longer printsslog.Warn("ImportValues missing table…")in either form. - Messages go through
log.Defaulttogether with the other skipped export/import messages, e.g.:Skipping export-values of "img.repoo" from chart "p" to dependency "sub": the path is not set in any values Skipping import-values of "out" from dependency "sub" to chart "q": no map is set at the path in any values
Why
Since #775 the chart-level pass sees only chart values, so it cannot tell that a path is missing: it may be set only in values files, set values or extra values. #775 therefore demoted the export warning to slog.Debug, which nelm never shows, so typos became silent. The import side still warned whenever the table was set only in user or extra values, even though the import worked. Export/import are applied per layer, so only all layers together can tell that a path is set nowhere.
Behaviour change
Log only, rendering is unchanged.
- New warning for an
export-valuesparent path or animport-valueschild path that is set nowhere, e.g. a typo in Chart.yaml. ImportValues missing table(stderr,level=WARN) is no longer printed. A table set nowhere is reported by the new warning instead.- Pure nelm on a werf chart:
werf.*/global.werf.*export sources come from the extra values werf passes. Running plainnelm chart renderon such a chart without them prints the new warning for those exports. Withwerf render/werf convergethere is no warning. This is expected.
Known limitations (warning only)
- An export whose source exists only between two other exports, i.e. created by one export and overwritten by a later one, is reported as missing.
- An export in a nested chart whose parent path is set only in the root chart's values.yaml under that nested chart's key is not applied by the chart-level pass (existing behaviour), and the check does not warn about it.
Tests
TestRenderChart_ExportAndImportValuesNotFoundWarnings:
- typo → exactly one warning;
- paths only in
--set, only in a values file, only in extra values, only in chart values → no warning; - disabled dependency → no warning, enabled → warnings;
- nested chart values overridden by the parent;
- export cycles, a self-overwriting export and a typo inside a cycle;
- scalar import sources in chart values (both forms);
- a chart without
dependencies:whose values are valid only with--set.
Each case fails without the fix, and slog stays silent. TestRenderChart_ExportedValueOverridesValuesFileForDependencyWithSameNameAsParent (#775) now also asserts no skipped-warnings.