#11373 Improve the text of the error message and include more info

Signed-off-by: Vincent van ’t Zand <vovtz@users.noreply.github.com>
pull/11374/head
Vincent van ’t Zand 3 years ago
parent b5e39c15ea
commit 478ed61253

@ -56,7 +56,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
// Now we clone the dependencies, locking as we go. // Now we clone the dependencies, locking as we go.
locked := make([]*chart.Dependency, len(reqs)) locked := make([]*chart.Dependency, len(reqs))
missing := []string{} missing := make(map[string]string)
for i, d := range reqs { for i, d := range reqs {
constraint, err := semver.NewConstraint(d.Version) constraint, err := semver.NewConstraint(d.Version)
if err != nil { if err != nil {
@ -95,7 +95,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
} }
if !constraint.Check(v) { if !constraint.Check(v) {
missing = append(missing, d.Name) addMissingChart(missing, d)
continue continue
} }
@ -173,7 +173,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
Repository: d.Repository, Repository: d.Repository,
Version: version, Version: version,
} }
// The version are already sorted and hence the first one to satisfy the constraint is used // The versions are already sorted and hence the first one to satisfy the constraint is used
for _, ver := range vs { for _, ver := range vs {
v, err := semver.NewVersion(ver.Version) v, err := semver.NewVersion(ver.Version)
// OCI does not need URLs // OCI does not need URLs
@ -189,11 +189,16 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
} }
if !found { if !found {
missing = append(missing, d.Name) addMissingChart(missing, d)
} }
} }
if len(missing) > 0 { if len(missing) > 0 {
return nil, errors.Errorf("can't get a valid version for repositories %s. Try changing the version constraint in Chart.yaml", strings.Join(missing, ", ")) missingVersionsList := ""
for name, repo := range missing {
missingVersionsList += fmt.Sprintf("\n- %s in %s", name, repo)
}
return nil, errors.Errorf("can't find the specified chart version for these dependencies in their "+
"respective repos:\n%s\n\nTry changing the version constraint(s) in the 'Chart.yaml' file.", missingVersionsList)
} }
digest, err := HashReq(reqs, locked) digest, err := HashReq(reqs, locked)
@ -208,6 +213,10 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
}, nil }, nil
} }
func addMissingChart(missing map[string]string, d *chart.Dependency) {
missing[fmt.Sprintf("%s (%s)", d.Name, d.Version)] = d.Repository
}
// HashReq generates a hash of the dependencies. // HashReq generates a hash of the dependencies.
// //
// This should be used only to compare against another hash generated by this // This should be used only to compare against another hash generated by this

Loading…
Cancel
Save