From dd0b8f40babfefa3b38351bc15b9c8a765532b37 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 25 Feb 2026 00:39:53 +0100 Subject: [PATCH] fix(schema): limit $ref resolution to lint command Schema validation with $ref cross-file references only works when charts are available as directories on the filesystem. The install, template, and upgrade commands may work with archived charts (.tgz) that are loaded directly into memory without filesystem extraction. This change limits ChartDir setting to the lint command only. The lint command already extracts archived charts to temporary directories before validation, so $ref resolution works for both directory and archived charts when linting. For install/template/upgrade commands: - Main schema validation continues to work - Charts without $ref validate successfully - Charts with $ref will fail .. maybe we could add a warning about $ref not being supported in these commands? Changes: - Remove ChartDir assignment from install and upgrade commands - Update schema validation to use synthetic path when chartDir is empty - Add test for linting archived chart with $ref - Remove install/template/upgrade tests for $ref (not supported) Signed-off-by: Benoit Tigeot --- pkg/action/lint_test.go | 4 +++ .../testdata/charts/chart-with-schema-ref.tgz | Bin 0 -> 397 bytes pkg/chart/common/util/jsonschema.go | 28 +++++++++++++----- pkg/cmd/install.go | 1 - pkg/cmd/install_test.go | 5 ---- pkg/cmd/template_test.go | 5 ---- pkg/cmd/testdata/output/schema-ref.txt | 7 ----- .../testdata/output/template-schema-ref.txt | 1 - .../testdata/output/upgrade-schema-ref.txt | 8 ----- .../chart-with-schema-ref/Chart.yaml | 3 -- .../chart-with-schema-ref/name.schema.json | 4 --- .../chart-with-schema-ref/values.schema.json | 7 ----- .../chart-with-schema-ref/values.yaml | 1 - pkg/cmd/upgrade.go | 1 - pkg/cmd/upgrade_test.go | 6 ---- 15 files changed, 24 insertions(+), 57 deletions(-) create mode 100644 pkg/action/testdata/charts/chart-with-schema-ref.tgz delete mode 100644 pkg/cmd/testdata/output/schema-ref.txt delete mode 100644 pkg/cmd/testdata/output/template-schema-ref.txt delete mode 100644 pkg/cmd/testdata/output/upgrade-schema-ref.txt delete mode 100644 pkg/cmd/testdata/testcharts/chart-with-schema-ref/Chart.yaml delete mode 100644 pkg/cmd/testdata/testcharts/chart-with-schema-ref/name.schema.json delete mode 100644 pkg/cmd/testdata/testcharts/chart-with-schema-ref/values.schema.json delete mode 100644 pkg/cmd/testdata/testcharts/chart-with-schema-ref/values.yaml diff --git a/pkg/action/lint_test.go b/pkg/action/lint_test.go index 63b2f51ae..08329ad6c 100644 --- a/pkg/action/lint_test.go +++ b/pkg/action/lint_test.go @@ -75,6 +75,10 @@ func TestLintChart(t *testing.T) { name: "chart-with-schema-ref", chartPath: "testdata/charts/chart-with-schema-ref", }, + { + name: "archived-chart-with-schema-ref", + chartPath: "testdata/charts/chart-with-schema-ref.tgz", + }, { name: "chart-with-schema-negative", chartPath: "testdata/charts/chart-with-schema-negative", diff --git a/pkg/action/testdata/charts/chart-with-schema-ref.tgz b/pkg/action/testdata/charts/chart-with-schema-ref.tgz new file mode 100644 index 0000000000000000000000000000000000000000..da12c8d095ff48f06bd876c37125ae1fa7121a46 GIT binary patch literal 397 zcmV;80doEyiwFR4HJ)hz1MQYeZi6rohFNn8%k8rG1vV1f-l2OZHGwDrWIL&%DtE6P zQW{lNvH_|n{uWpawr61c&wy|=IfRg$b8s3(ei{kO`tb~)oMu80LQ?|Vg)$KVK7D9W zv@=#}7s^64ZEcaQSE{vt%yZMq^2$Ev_ZY@I0pZt5YKsnXyP3*|`yL|8uH-*weg0FC zrFrJ^&qcU4gMb z250S~R