docker: improve error message for auth helper

The error returned from the stdlib's `exec` package is always a message with
the exit code of the exec'd process, not any error message that process might
have given us. This results in opaque failures for the Nomad user. Cast to an
`ExitError` so that we can access the output from stderr.
This commit is contained in:
Tim Gross
2021-05-03 08:51:26 -04:00
committed by Tim Gross
parent 8fc3411051
commit f4de94c6d8

View File

@@ -156,12 +156,12 @@ func authFromHelper(helperName string) authBackend {
cmd.Stdin = strings.NewReader(repoInfo.Index.Name)
output, err := cmd.Output()
if err != nil {
switch err.(type) {
default:
return nil, err
case *exec.ExitError:
return nil, fmt.Errorf("%s with input %q failed with stderr: %s", helper, repo, err.Error())
exitErr, ok := err.(*exec.ExitError)
if ok {
return nil, fmt.Errorf(
"%s with input %q failed with stderr: %s", helper, repo, exitErr.Stderr)
}
return nil, err
}
var response map[string]string