Merge pull request #30648 from allencloud/do-not-fail-fast-when-inspect

do not fail fast when executing inspect command
This commit is contained in:
Sebastiaan van Stijn 2017-03-13 16:04:04 +01:00 committed by GitHub
commit be1855fac4
1 changed files with 10 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"strings"
"text/template"
"github.com/Sirupsen/logrus"
@ -60,17 +61,16 @@ func Inspect(out io.Writer, references []string, tmplStr string, getRef GetRefFu
return cli.StatusError{StatusCode: 64, Status: err.Error()}
}
var inspectErr error
var inspectErrs []string
for _, ref := range references {
element, raw, err := getRef(ref)
if err != nil {
inspectErr = err
break
inspectErrs = append(inspectErrs, err.Error())
continue
}
if err := inspector.Inspect(element, raw); err != nil {
inspectErr = err
break
inspectErrs = append(inspectErrs, err.Error())
}
}
@ -78,8 +78,11 @@ func Inspect(out io.Writer, references []string, tmplStr string, getRef GetRefFu
logrus.Errorf("%s\n", err)
}
if inspectErr != nil {
return cli.StatusError{StatusCode: 1, Status: inspectErr.Error()}
if len(inspectErrs) != 0 {
return cli.StatusError{
StatusCode: 1,
Status: strings.Join(inspectErrs, "\n"),
}
}
return nil
}