mirror of https://github.com/docker/cli.git
do not fail fast when executing inspect command
Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
parent
50a10e9bf4
commit
49570cf783
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"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()}
|
return cli.StatusError{StatusCode: 64, Status: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
var inspectErr error
|
var inspectErrs []string
|
||||||
for _, ref := range references {
|
for _, ref := range references {
|
||||||
element, raw, err := getRef(ref)
|
element, raw, err := getRef(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
inspectErr = err
|
inspectErrs = append(inspectErrs, err.Error())
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := inspector.Inspect(element, raw); err != nil {
|
if err := inspector.Inspect(element, raw); err != nil {
|
||||||
inspectErr = err
|
inspectErrs = append(inspectErrs, err.Error())
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,11 @@ func Inspect(out io.Writer, references []string, tmplStr string, getRef GetRefFu
|
||||||
logrus.Errorf("%s\n", err)
|
logrus.Errorf("%s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if inspectErr != nil {
|
if len(inspectErrs) != 0 {
|
||||||
return cli.StatusError{StatusCode: 1, Status: inspectErr.Error()}
|
return cli.StatusError{
|
||||||
|
StatusCode: 1,
|
||||||
|
Status: strings.Join(inspectErrs, "\n"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue