mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fix status code
This commit is contained in:
parent
8bce284496
commit
01284cbf73
1 changed files with 7 additions and 1 deletions
|
@ -579,6 +579,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
indented := new(bytes.Buffer)
|
indented := new(bytes.Buffer)
|
||||||
|
status := 0
|
||||||
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
obj, _, err := cli.call("GET", "/containers/"+name+"/json", nil)
|
obj, _, err := cli.call("GET", "/containers/"+name+"/json", nil)
|
||||||
|
@ -586,12 +587,14 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
|
||||||
obj, _, err = cli.call("GET", "/images/"+name+"/json", nil)
|
obj, _, err = cli.call("GET", "/images/"+name+"/json", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(cli.err, "No such image or container: %s\n", name)
|
fmt.Fprintf(cli.err, "No such image or container: %s\n", name)
|
||||||
|
status = 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = json.Indent(indented, obj, "", " "); err != nil {
|
if err = json.Indent(indented, obj, "", " "); err != nil {
|
||||||
fmt.Fprintf(cli.err, "%s\n", err)
|
fmt.Fprintf(cli.err, "%s\n", err)
|
||||||
|
status = 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
indented.WriteString(",")
|
indented.WriteString(",")
|
||||||
|
@ -601,9 +604,12 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
|
||||||
|
|
||||||
fmt.Fprintf(cli.out, "[")
|
fmt.Fprintf(cli.out, "[")
|
||||||
if _, err := io.Copy(cli.out, indented); err != nil {
|
if _, err := io.Copy(cli.out, indented); err != nil {
|
||||||
fmt.Fprintf(cli.err, "%s\n", err)
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(cli.out, "]")
|
fmt.Fprintf(cli.out, "]")
|
||||||
|
if status != 0 {
|
||||||
|
return &utils.StatusError{Status: status}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue