github.com/skanehira/moby@v17.12.1-ce-rc2+incompatible/client/image_inspect.go (about) 1 package client 2 3 import ( 4 "bytes" 5 "encoding/json" 6 "io/ioutil" 7 8 "github.com/docker/docker/api/types" 9 "golang.org/x/net/context" 10 ) 11 12 // ImageInspectWithRaw returns the image information and its raw representation. 13 func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { 14 serverResp, err := cli.get(ctx, "/images/"+imageID+"/json", nil, nil) 15 if err != nil { 16 return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID) 17 } 18 defer ensureReaderClosed(serverResp) 19 20 body, err := ioutil.ReadAll(serverResp.body) 21 if err != nil { 22 return types.ImageInspect{}, nil, err 23 } 24 25 var response types.ImageInspect 26 rdr := bytes.NewReader(body) 27 err = json.NewDecoder(rdr).Decode(&response) 28 return response, body, err 29 }