github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/client/distribution_inspect.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 "net/url" 6 7 registrytypes "github.com/docker/docker/api/types/registry" 8 "golang.org/x/net/context" 9 ) 10 11 // DistributionInspect returns the image digest with full Manifest 12 func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) { 13 // Contact the registry to retrieve digest and platform information 14 var distributionInspect registrytypes.DistributionInspect 15 16 if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil { 17 return distributionInspect, err 18 } 19 var headers map[string][]string 20 21 if encodedRegistryAuth != "" { 22 headers = map[string][]string{ 23 "X-Registry-Auth": {encodedRegistryAuth}, 24 } 25 } 26 27 resp, err := cli.get(ctx, "/distribution/"+image+"/json", url.Values{}, headers) 28 if err != nil { 29 return distributionInspect, err 30 } 31 32 err = json.NewDecoder(resp.body).Decode(&distributionInspect) 33 ensureReaderClosed(resp) 34 return distributionInspect, err 35 }