fix: --include-needs should only include direct dependencies

Fixes #1003

Previously, --include-needs was incorrectly including transitive
dependencies (dependencies of dependencies). This fix ensures that:

- --include-needs only includes direct needs
- --include-transitive-needs includes both direct and transitive needs

Changes:
- Add separate handling for direct vs transitive needs in state.go
- Add IncludeNeeds field to ChartPrepareOptions
- Add unmarkNeedsDirectOnly() and collectDirectNeedsOnly() functions
- Update ForEachState and related functions to accept both flags
- Fix incorrect usage of c.IncludeNeeds() for IncludeTransitiveNeeds
- Update tests to verify the correct behavior

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2026-03-18 08:25:32 +08:00
committed by yxxhero
parent 97b3256058
commit 72a8727d17
17 changed files with 135 additions and 89 deletions
+8 -4
View File
@@ -57,7 +57,8 @@ releases:
err = app.ForEachState(
Noop,
false,
SetFilter(true),
false,SetFilter(true),
)
if err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -192,7 +193,8 @@ releases:
err = app.ForEachState(
noop,
false,
SetFilter(true),
false,SetFilter(true),
)
if err != nil {
t.Fatalf("unexpected error: %v", err)
@@ -405,7 +407,8 @@ releases:
err = app.ForEachState(
failingConverge,
false,
SetFilter(true),
false,SetFilter(true),
)
if err == nil {
@@ -472,7 +475,8 @@ replicaCount: 3
err = app.ForEachState(
captureState,
false,
SetFilter(true),
false,SetFilter(true),
)
if err != nil {
t.Fatalf("unexpected error: %v", err)