fix: --include-needs should only include direct dependencies (#1003)

--include-needs was incorrectly including transitive dependencies when
it should only include direct dependencies per the documentation.

The issue was that ChartPrepareOptions.IncludeTransitiveNeeds was being
set to c.IncludeNeeds() instead of c.IncludeTransitiveNeeds() in the
chart preparation phase for diff, template, lint, sync, and apply commands.

This fix ensures:
- --include-needs includes only direct dependencies
- --include-transitive-needs includes both direct and transitive dependencies

Fixes #1003

Signed-off-by: yxxhero <yxxhero@users.noreply.github.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
(cherry picked from commit 7a2cbeebb8)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2026-03-13 13:21:48 +08:00
parent 8301c491ca
commit 47c7b75ba3
6 changed files with 165 additions and 7 deletions
+5 -5
View File
@@ -169,7 +169,7 @@ func (a *App) Diff(c DiffConfigProvider) error {
IncludeCRDs: &includeCRDs,
Validate: c.Validate(),
Concurrency: c.Concurrency(),
IncludeTransitiveNeeds: c.IncludeNeeds(),
IncludeTransitiveNeeds: c.IncludeTransitiveNeeds(),
}, func() {
msg, matched, affected, errs = a.diff(run, c)
})
@@ -240,7 +240,7 @@ func (a *App) Template(c TemplateConfigProvider) error {
SkipCleanup: c.SkipCleanup(),
Validate: c.Validate(),
Concurrency: c.Concurrency(),
IncludeTransitiveNeeds: c.IncludeNeeds(),
IncludeTransitiveNeeds: c.IncludeTransitiveNeeds(),
Set: c.Set(),
Values: c.Values(),
KubeVersion: c.KubeVersion(),
@@ -317,7 +317,7 @@ func (a *App) Lint(c LintConfigProvider) error {
SkipDeps: c.SkipDeps(),
SkipCleanup: c.SkipCleanup(),
Concurrency: c.Concurrency(),
IncludeTransitiveNeeds: c.IncludeNeeds(),
IncludeTransitiveNeeds: c.IncludeTransitiveNeeds(),
}, func() {
ok, lintErrs, errs = a.lint(run, c)
})
@@ -417,7 +417,7 @@ func (a *App) Sync(c SyncConfigProvider) error {
WaitRetries: c.WaitRetries(),
WaitForJobs: c.WaitForJobs(),
IncludeCRDs: &includeCRDs,
IncludeTransitiveNeeds: c.IncludeNeeds(),
IncludeTransitiveNeeds: c.IncludeTransitiveNeeds(),
Validate: c.Validate(),
Concurrency: c.Concurrency(),
}, func() {
@@ -455,7 +455,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
SkipCleanup: c.SkipCleanup(),
Validate: c.Validate(),
Concurrency: c.Concurrency(),
IncludeTransitiveNeeds: c.IncludeNeeds(),
IncludeTransitiveNeeds: c.IncludeTransitiveNeeds(),
}, func() {
matched, updated, es := a.apply(run, c)
+1 -2
View File
@@ -205,9 +205,8 @@ releases:
error: ``,
selectors: []string{"app=test"},
// Issue #2309: --kube-context is now added to template flags
// Issue #1003: --include-needs should only include direct dependencies, not transitive
templated: []exectest.Release{
// TODO: Turned out we can't differentiate needs vs transitive needs in this case :thinking:
{Name: "logging", Flags: []string{"--kube-context", "default", "--namespace", "kube-system"}},
{Name: "kubernetes-external-secrets", Flags: []string{"--kube-context", "default", "--namespace", "kube-system"}},
{Name: "external-secrets", Flags: []string{"--kube-context", "default", "--namespace", "default"}},
{Name: "my-release", Flags: []string{"--kube-context", "default", "--namespace", "default"}},