improve plugin error formatting
Remove "checksum" from the error, and only indicate that the plugin has changed. Always show requested versions even if it's "any", and found versions of plugins.
This commit is contained in:
parent
ac937a890d
commit
4893fcc24f
|
@ -46,7 +46,7 @@ func (r *multiVersionProviderResolver) ResolveProviders(
|
|||
var errs []error
|
||||
|
||||
chosen := choosePlugins(r.Available, reqd)
|
||||
for name := range reqd {
|
||||
for name, req := range reqd {
|
||||
if newest, available := chosen[name]; available {
|
||||
digest, err := newest.SHA256()
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func (r *multiVersionProviderResolver) ResolveProviders(
|
|||
continue
|
||||
}
|
||||
if !reqd[name].AcceptsSHA256(digest) {
|
||||
errs = append(errs, fmt.Errorf("provider.%s: checksum mismatch", name))
|
||||
errs = append(errs, fmt.Errorf("provider.%s: new or changed plugin executable", name))
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -63,20 +63,24 @@ func (r *multiVersionProviderResolver) ResolveProviders(
|
|||
} else {
|
||||
msg := fmt.Sprintf("provider.%s: no suitable version installed", name)
|
||||
|
||||
if req := reqd[name]; req.Versions.String() != "" {
|
||||
foundVersions := []string{}
|
||||
for meta := range r.Available.WithName(name) {
|
||||
foundVersions = append(foundVersions, fmt.Sprintf("%q", meta.Version))
|
||||
}
|
||||
|
||||
found := "none"
|
||||
if len(foundVersions) > 0 {
|
||||
found = strings.Join(foundVersions, ", ")
|
||||
}
|
||||
|
||||
msg += fmt.Sprintf("\n version requirements: %q\n versions found: %s", req.Versions, found)
|
||||
required := req.Versions.String()
|
||||
// no version is unconstrained
|
||||
if required == "" {
|
||||
required = "(any version)"
|
||||
}
|
||||
|
||||
foundVersions := []string{}
|
||||
for meta := range r.Available.WithName(name) {
|
||||
foundVersions = append(foundVersions, fmt.Sprintf("%q", meta.Version))
|
||||
}
|
||||
|
||||
found := "none"
|
||||
if len(foundVersions) > 0 {
|
||||
found = strings.Join(foundVersions, ", ")
|
||||
}
|
||||
|
||||
msg += fmt.Sprintf("\n version requirements: %q\n versions installed: %s", required, found)
|
||||
|
||||
errs = append(errs, errors.New(msg))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue