1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #13141 from vieux/fallback_inspect

fallback to interface with docker inspect
This commit is contained in:
Jessie Frazelle 2015-05-12 11:02:06 -07:00
commit d4eba30065

View file

@ -59,7 +59,8 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
continue
}
} else {
dec := json.NewDecoder(bytes.NewReader(obj))
rdr := bytes.NewReader(obj)
dec := json.NewDecoder(rdr)
if isImage {
inspPtr := types.ImageInspect{}
@ -69,8 +70,15 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
continue
}
if err := tmpl.Execute(cli.out, inspPtr); err != nil {
rdr.Seek(0, 0)
var raw interface{}
if err := dec.Decode(&raw); err != nil {
return err
}
if err = tmpl.Execute(cli.out, raw); err != nil {
return err
}
}
} else {
inspPtr := types.ContainerJSON{}
if err := dec.Decode(&inspPtr); err != nil {
@ -79,8 +87,14 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
continue
}
if err := tmpl.Execute(cli.out, inspPtr); err != nil {
rdr.Seek(0, 0)
var raw interface{}
if err := dec.Decode(&raw); err != nil {
return err
}
if err = tmpl.Execute(cli.out, raw); err != nil {
return err
}
}
}
cli.out.Write([]byte{'\n'})