diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 2c9923ea0..f6ac210ee 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -271,7 +271,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { defer os.RemoveAll(tmpPath) fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps)) - var saveError error + var saveErrors []error churls := make(map[string]struct{}) for _, dep := range deps { // No repository means the chart is in charts directory @@ -295,7 +295,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } if !constraint.Check(v) { - saveError = fmt.Errorf("dependency %s at version %s does not satisfy the constraint %s", dep.Name, ch.Metadata.Version, dep.Version) + saveErrors = append(saveErrors, fmt.Errorf("dependency %s at version %s does not satisfy the constraint %s", dep.Name, ch.Metadata.Version, dep.Version)) break } continue @@ -306,7 +306,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } ver, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version, tmpPath) if err != nil { - saveError = err + saveErrors = append(saveErrors, err) break } dep.Version = ver @@ -317,7 +317,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { // https://github.com/helm/helm/issues/1439 churl, username, password, insecureskiptlsverify, passcredentialsall, caFile, certFile, keyFile, err := m.findChartURL(dep.Name, dep.Version, dep.Repository, repos) if err != nil { - saveError = fmt.Errorf("could not find %s: %w", churl, err) + saveErrors = append(saveErrors, fmt.Errorf("could not find %s: %w", churl, err)) break } @@ -358,7 +358,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { _, v, err := dl.DownloadTo(churl, version, tmpPath) if err != nil { - saveError = fmt.Errorf("could not download %s: %w", churl, err) + saveErrors = append(saveErrors, fmt.Errorf("could not download %s: %w", churl, err)) break } @@ -377,15 +377,14 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { churls[churl] = struct{}{} } - // TODO: this should probably be refactored to be a []error, so we can capture and provide more information rather than "last error wins". - if saveError == nil { + if saveErrors == nil { // now we can move all downloaded charts to destPath and delete outdated dependencies if err := m.safeMoveDeps(deps, tmpPath, destPath); err != nil { return err } } else { - fmt.Fprintln(m.Out, "Save error occurred: ", saveError) - return saveError + fmt.Fprintln(m.Out, "Save error occurred: ", saveErrors) + return errors.Join(saveErrors...) } return nil }