github.com/rish1988/moby@v25.0.2+incompatible/client/distribution_inspect.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "encoding/json" 6 "net/http" 7 "net/url" 8 9 "github.com/docker/docker/api/types/registry" 10 ) 11 12 // DistributionInspect returns the image digest with the full manifest. 13 func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error) { 14 // Contact the registry to retrieve digest and platform information 15 var distributionInspect registry.DistributionInspect 16 if imageRef == "" { 17 return distributionInspect, objectNotFoundError{object: "distribution", id: imageRef} 18 } 19 20 if err := cli.NewVersionError(ctx, "1.30", "distribution inspect"); err != nil { 21 return distributionInspect, err 22 } 23 24 var headers http.Header 25 if encodedRegistryAuth != "" { 26 headers = http.Header{ 27 registry.AuthHeader: {encodedRegistryAuth}, 28 } 29 } 30 31 resp, err := cli.get(ctx, "/distribution/"+imageRef+"/json", url.Values{}, headers) 32 defer ensureReaderClosed(resp) 33 if err != nil { 34 return distributionInspect, err 35 } 36 37 err = json.NewDecoder(resp.body).Decode(&distributionInspect) 38 return distributionInspect, err 39 }