fix: warn about export-values and import-values paths set in no values

Merged
IL
2d ago
+453-11

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 ExportAndImportValuesNotFoundWarnings in pkg/helm/pkg/chart/v2/util/dependencies_nelm.go (the upstream dependencies.go keeps only the call and the removed warnings), called once from processDependencies (render) and from ProcessDependencies (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 imported message.
    • Disabled dependencies (condition/tags) are not checked.
  • The chart-level processImportValues no longer prints slog.Warn("ImportValues missing table…") in either form.
  • Messages go through log.Default together 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-values parent path or an import-values child 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 plain nelm chart render on such a chart without them prints the new warning for those exports. With werf render/werf converge there 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.