diff --git a/pkg/app/app.go b/pkg/app/app.go index f3c53520..feacef32 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -2346,11 +2346,7 @@ func (a *App) withNeeds(r *Run, c DAGConfig, includeDisabled bool, f func(*state var rels []state.ReleaseSpec if len(toRender) > 0 { - // toRender already contains the direct and transitive needs depending on the DAG options. - // That's why we don't pass in `IncludeNeeds: c.IncludeNeeds(), IncludeTransitiveNeeds: c.IncludeTransitiveNeeds()` here. - // Otherwise, in case include-needs=true, it will include the needs of needs, which results in unexpectedly introducing transitive needs, - // even if include-transitive-needs=true is unspecified. - if _, errs := withDAG(st, r.helm, a.Logger, state.PlanOptions{SelectedReleases: toRender, Reverse: false, SkipNeeds: c.SkipNeeds(), IncludeNeeds: includeNeeds}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error { + if _, errs := withDAG(st, r.helm, a.Logger, state.PlanOptions{SelectedReleases: toRender, Reverse: false, SkipNeeds: c.SkipNeeds(), IncludeNeeds: includeNeeds, IncludeTransitiveNeeds: c.IncludeTransitiveNeeds()}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error { rels = append(rels, subst.Releases...) return nil })); len(errs) > 0 { diff --git a/pkg/app/testdata/app_diff_test/include-transitive-needs b/pkg/app/testdata/app_diff_test/include-transitive-needs index 2e043346..58431a7a 100644 --- a/pkg/app/testdata/app_diff_test/include-transitive-needs +++ b/pkg/app/testdata/app_diff_test/include-transitive-needs @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -2 release(s) matching app=test found in helmfile.yaml +4 release(s) matching app=test found in helmfile.yaml processing 4 groups of releases in this order: GROUP RELEASES diff --git a/pkg/app/testdata/app_diff_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need b/pkg/app/testdata/app_diff_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need index b8b28277..e1982cb0 100644 --- a/pkg/app/testdata/app_diff_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need +++ b/pkg/app/testdata/app_diff_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -1 release(s) matching name=test3 found in helmfile.yaml +2 release(s) matching name=test3 found in helmfile.yaml processing 2 groups of releases in this order: GROUP RELEASES diff --git a/pkg/app/testdata/app_lint_test/include-transitive-needs b/pkg/app/testdata/app_lint_test/include-transitive-needs index 2e043346..58431a7a 100644 --- a/pkg/app/testdata/app_lint_test/include-transitive-needs +++ b/pkg/app/testdata/app_lint_test/include-transitive-needs @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -2 release(s) matching app=test found in helmfile.yaml +4 release(s) matching app=test found in helmfile.yaml processing 4 groups of releases in this order: GROUP RELEASES diff --git a/pkg/app/testdata/app_lint_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need b/pkg/app/testdata/app_lint_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need index 3a218076..285e8e6f 100644 --- a/pkg/app/testdata/app_lint_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need +++ b/pkg/app/testdata/app_lint_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -1 release(s) matching name=test3 found in helmfile.yaml +2 release(s) matching name=test3 found in helmfile.yaml processing 2 groups of releases in this order: GROUP RELEASES diff --git a/pkg/app/testdata/app_template_test/include-transitive-needs b/pkg/app/testdata/app_template_test/include-transitive-needs index 2e043346..58431a7a 100644 --- a/pkg/app/testdata/app_template_test/include-transitive-needs +++ b/pkg/app/testdata/app_template_test/include-transitive-needs @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -2 release(s) matching app=test found in helmfile.yaml +4 release(s) matching app=test found in helmfile.yaml processing 4 groups of releases in this order: GROUP RELEASES diff --git a/pkg/app/testdata/app_template_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need b/pkg/app/testdata/app_template_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need index b8b28277..e1982cb0 100644 --- a/pkg/app/testdata/app_template_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need +++ b/pkg/app/testdata/app_template_test/include-transitive-needs_should_not_fail_on_disabled_transitive_need @@ -1,6 +1,6 @@ merged environment: &{default map[] map[] map[]} WARNING: release test2 needs disabled, but disabled is not installed due to installed: false. Either mark disabled as installed or remove disabled from test2's needs -1 release(s) matching name=test3 found in helmfile.yaml +2 release(s) matching name=test3 found in helmfile.yaml processing 2 groups of releases in this order: GROUP RELEASES diff --git a/pkg/state/state.go b/pkg/state/state.go index 569e5fd1..3fcff3a1 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -2965,6 +2965,7 @@ func (st *HelmState) SelectReleasesWithNeeds(includeTransitiveNeeds bool) ([]Rel } func markExcludedReleases(releases []ReleaseSpec, selectors []string, values map[string]any, includeTransitiveNeeds bool, includeNeeds bool) ([]Release, error) { + var filteredReleases []Release filters := []ReleaseFilter{} for _, label := range selectors { @@ -3093,7 +3094,8 @@ func collectAllNeedsWithTransitives(filteredReleases []Release, allReleases []Re func unmarkReleases(toUnmark map[string]struct{}, releases []Release) { for i, r := range releases { - if _, ok := toUnmark[ReleaseToID(&r.ReleaseSpec)]; ok { + releaseID := ReleaseToID(&r.ReleaseSpec) + if _, ok := toUnmark[releaseID]; ok { releases[i].Filtered = false } }