From 79948e39fc16a68f2bfb261211437abf8e6cb555 Mon Sep 17 00:00:00 2001 From: Cayan <1619617+Cayan@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:05:11 -0300 Subject: [PATCH 1/2] feat: let ad-hoc chart dependencies override their condition - ChartDependency gains an optional Condition, written to the dependency's `condition` in the generated Chart.yaml. Left empty, it keeps the current `.enabled`, so existing callers see no change. - A test covers an aliased local dependency with an explicit condition. Signed-off-by: Cayan <1619617+Cayan@users.noreply.github.com> --- chartify.go | 7 ++++++- chartify_test.go | 20 ++++++++++++++++++++ requirements.go | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/chartify.go b/chartify.go index 3422217..c310bb3 100644 --- a/chartify.go +++ b/chartify.go @@ -624,10 +624,15 @@ func (r *Runner) ReadAdhocDependencies(u *ChartifyOpts) ([]Dependency, error) { condName = name } + condition := d.Condition + if condition == "" { + condition = fmt.Sprintf("%s.enabled", condName) + } + deps = append(deps, Dependency{ Name: name, Repository: repoUrl, - Condition: fmt.Sprintf("%s.enabled", condName), + Condition: condition, Alias: d.Alias, Version: d.Version, }) diff --git a/chartify_test.go b/chartify_test.go index eb53096..539d968 100644 --- a/chartify_test.go +++ b/chartify_test.go @@ -65,6 +65,26 @@ func TestReadAdhocDependencies(t *testing.T) { }, }) + run(testcase{ + opts: ChartifyOpts{ + AdhocChartDependencies: []ChartDependency{ + { + Alias: "mydb", + Chart: "./testdata/charts/db", + Condition: "global.mydb.enabled", + }, + }, + }, + wantDendency: []Dependency{ + { + Repository: "file://./testdata/charts/db", + Name: "db", + Alias: "mydb", + Condition: "global.mydb.enabled", + }, + }, + }) + run(testcase{ opts: ChartifyOpts{ AdhocChartDependencies: []ChartDependency{ diff --git a/requirements.go b/requirements.go index 6a86414..ef80a2b 100644 --- a/requirements.go +++ b/requirements.go @@ -27,6 +27,9 @@ type ChartDependency struct { Alias string Chart string Version string + // Condition is written to the dependency's `condition` field. + // When empty, it defaults to `.enabled`. + Condition string } // UpdateRequirements updates either Chart.yaml's dependencies(helm 3) or requirements.yaml(helm 2) From 657670cee8eef40e74edc230763070510f009bb2 Mon Sep 17 00:00:00 2001 From: Cayan <1619617+Cayan@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:35:42 -0300 Subject: [PATCH 2/2] test: default condition uses the alias over the chart name Signed-off-by: Cayan <1619617+Cayan@users.noreply.github.com> --- chartify_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/chartify_test.go b/chartify_test.go index 539d968..f69abed 100644 --- a/chartify_test.go +++ b/chartify_test.go @@ -85,6 +85,25 @@ func TestReadAdhocDependencies(t *testing.T) { }, }) + run(testcase{ + opts: ChartifyOpts{ + AdhocChartDependencies: []ChartDependency{ + { + Alias: "mydb", + Chart: "./testdata/charts/db", + }, + }, + }, + wantDendency: []Dependency{ + { + Repository: "file://./testdata/charts/db", + Name: "db", + Alias: "mydb", + Condition: "mydb.enabled", + }, + }, + }) + run(testcase{ opts: ChartifyOpts{ AdhocChartDependencies: []ChartDependency{