From 441c9ba4249d16fbe706bb8979ed842524c31ebc Mon Sep 17 00:00:00 2001 From: S Code Man <30977678+scodeman@users.noreply.github.com> Date: Tue, 4 Feb 2025 08:00:04 +0000 Subject: [PATCH] fix: add child/parent support to import-values --- requirements.go | 14 ++++++++------ testdata/charts/importvalues/Chart.yaml | 2 ++ .../charts/importvalues/charts/mydep-1.0.0.tgz | Bin 287 -> 297 bytes testdata/charts/importvalues/mydep/values.yaml | 3 +++ .../importvalues/templates/configmap.yaml | 1 + .../local_chart_with_import_values/want | 1 + 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/requirements.go b/requirements.go index 26cb1a1..e3620c2 100644 --- a/requirements.go +++ b/requirements.go @@ -13,12 +13,14 @@ type Requirements struct { } type Dependency struct { - Name string `yaml:"name,omitempty"` - Repository string `yaml:"repository,omitempty"` - Condition string `yaml:"condition,omitempty"` - Alias string `yaml:"alias,omitempty"` - Version string `yaml:"version,omitempty"` - ImportValues []string `yaml:"import-values,omitempty"` + Name string `yaml:"name,omitempty"` + Repository string `yaml:"repository,omitempty"` + Condition string `yaml:"condition,omitempty"` + Alias string `yaml:"alias,omitempty"` + Version string `yaml:"version,omitempty"` + // ImportValues holds the mapping of source values to parent key to be imported. Each item can be a + // string or pair of child/parent sublist items. + ImportValues []interface{} `yaml:"import-values,omitempty"` } type ChartDependency struct { diff --git a/testdata/charts/importvalues/Chart.yaml b/testdata/charts/importvalues/Chart.yaml index e9159fe..4992e34 100644 --- a/testdata/charts/importvalues/Chart.yaml +++ b/testdata/charts/importvalues/Chart.yaml @@ -9,3 +9,5 @@ dependencies: version: 1.0.0 import-values: - data + - child: data + parent: data diff --git a/testdata/charts/importvalues/charts/mydep-1.0.0.tgz b/testdata/charts/importvalues/charts/mydep-1.0.0.tgz index d556552835a6b98d47e8276be4d9bcba38722713..2f8f8c1ff426802afe794b5f8fb28fca98d89ad9 100644 GIT binary patch delta 246 zcmVn1Z_^5OqPcI3F%2k@Q$SgWo7TC42;Z@_PU w2q_u?&{Co$0o**1HE?%2330A|)^3iES?5e9leqxi0{{U3{~#vB^#BY201rfVx&QzG delta 236 zcmV5zC6ov_ctkZcoabwHB!KNuvNf z;xVN;Wr_m7eOKAsA38KCjtNf$EGXHH`^Zz6GHB2!l mD*<}Sv{eAVF61oST`o1cRaI60)LQ@m0RR65F5hba3;+PjR&)UX diff --git a/testdata/charts/importvalues/mydep/values.yaml b/testdata/charts/importvalues/mydep/values.yaml index 5020230..b09aef0 100644 --- a/testdata/charts/importvalues/mydep/values.yaml +++ b/testdata/charts/importvalues/mydep/values.yaml @@ -1,3 +1,6 @@ exports: data: myval: FOO + +data: + myval: BAR diff --git a/testdata/charts/importvalues/templates/configmap.yaml b/testdata/charts/importvalues/templates/configmap.yaml index 7a53a82..6d580db 100644 --- a/testdata/charts/importvalues/templates/configmap.yaml +++ b/testdata/charts/importvalues/templates/configmap.yaml @@ -5,3 +5,4 @@ metadata: namespace: {{ .Release.Namespace }} data: foo: {{ .Values.myval }} + bar: {{ .Values.data.myval }} diff --git a/testdata/integration/testcases/local_chart_with_import_values/want b/testdata/integration/testcases/local_chart_with_import_values/want index cb8724d..fe5ff6b 100644 --- a/testdata/integration/testcases/local_chart_with_import_values/want +++ b/testdata/integration/testcases/local_chart_with_import_values/want @@ -7,3 +7,4 @@ metadata: namespace: default data: foo: FOO + bar: BAR