Fix not to ignore diff selector when it matched nothing

Fixes #327

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Yusuke Kuoka
2022-09-19 04:46:52 +00:00
parent 24810a45ae
commit 6aeb6b38ba
4 changed files with 238 additions and 12 deletions
+14 -12
View File
@@ -1866,12 +1866,12 @@ func (a *App) withNeeds(r *Run, c DAGConfig, includeDisabled bool, f func(*state
var toRender []state.ReleaseSpec
releasesDisabled := map[string]state.ReleaseSpec{}
releasesToUninstall := map[string]state.ReleaseSpec{}
for _, r := range selectedReleasesWithNeeds {
release := r
id := state.ReleaseToID(&release)
if release.Installed != nil && !*release.Installed {
releasesDisabled[id] = release
releasesToUninstall[id] = release
} else {
toRender = append(toRender, release)
}
@@ -1879,19 +1879,21 @@ func (a *App) withNeeds(r *Run, c DAGConfig, includeDisabled bool, f func(*state
var rels []state.ReleaseSpec
// 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 {
rels = append(rels, subst.Releases...)
return nil
})); len(errs) > 0 {
return false, errs
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 {
rels = append(rels, subst.Releases...)
return nil
})); len(errs) > 0 {
return false, errs
}
}
if includeDisabled {
for _, d := range releasesDisabled {
for _, d := range releasesToUninstall {
rels = append(rels, d)
}
}