fix: address review feedback - remove WriteValuesImpl overrides, optimize debug log, add direct-only needs test

Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/c0b910d1-387a-476e-beb9-ea38ab6c1061
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 23:30:07 +00:00
parent fd9c2179fc
commit 4fada4f73c
3 changed files with 23 additions and 16 deletions

View File

@ -1617,11 +1617,17 @@ func (a *App) getSelectedReleases(r *Run, includeNeeds bool, includeTransitiveNe
extra = " matching " + strings.Join(r.state.Selectors, ",")
}
matchedOnly, err := r.state.GetSelectedReleases(false, false)
if err != nil {
return nil, nil, err
// When needs are included, we need a separate count of just the selector-matched releases
// for the debug log, so we don't count the included needs in the "found" message.
matchCount := len(selected)
if includeNeeds || includeTransitiveNeeds {
matchedOnly, err := r.state.GetSelectedReleases(false, false)
if err != nil {
return nil, nil, err
}
matchCount = len(matchedOnly)
}
a.Logger.Debugf("%d release(s)%s found in %s\n", len(matchedOnly), extra, r.state.FilePath)
a.Logger.Debugf("%d release(s)%s found in %s\n", matchCount, extra, r.state.FilePath)
return selected, deduplicated, nil
}

View File

@ -66,12 +66,3 @@ func (c *WriteValuesImpl) OutputFileTemplate() string {
return c.WriteValuesOptions.OutputFileTemplate
}
// SkipDeps returns the skip deps
func (c *WriteValuesImpl) SkipDeps() bool {
return false
}
// SkipRefresh returns the skip refresh
func (c *WriteValuesImpl) SkipRefresh() bool {
return false
}

View File

@ -139,20 +139,30 @@ func TestSelectReleasesWithOverridesWithIncludedTransitives(t *testing.T) {
subject string
selector []string
want []string
includeNeeds bool
includeTransitiveNeeds bool
}
testcases := []testcase{
{
subject: "include transitives is false",
subject: "no needs inclusion",
selector: []string{"name=serviceA"},
want: []string{"serviceA"},
includeNeeds: false,
includeTransitiveNeeds: false,
},
{
subject: "include transitives is true",
subject: "include direct needs only",
selector: []string{"name=serviceA"},
want: []string{"serviceA", "serviceB"},
includeNeeds: true,
includeTransitiveNeeds: false,
},
{
subject: "include transitive needs",
selector: []string{"name=serviceA"},
want: []string{"serviceA", "serviceB", "serviceC"},
includeNeeds: false,
includeTransitiveNeeds: true,
},
}
@ -192,7 +202,7 @@ func TestSelectReleasesWithOverridesWithIncludedTransitives(t *testing.T) {
}
state.Releases = state.GetReleasesWithLabels()
rs, err := state.GetSelectedReleases(tc.includeTransitiveNeeds, tc.includeTransitiveNeeds)
rs, err := state.GetSelectedReleases(tc.includeNeeds, tc.includeTransitiveNeeds)
if err != nil {
t.Fatalf("%s %s: %v", tc.selector, tc.subject, err)
}