1package client // import "github.com/docker/docker/client"
2
3import (
4	"context"
5	"encoding/json"
6	"net/url"
7
8	registrytypes "github.com/docker/docker/api/types/registry"
9)
10
11// DistributionInspect returns the image digest with full Manifest
12func (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	if image == "" {
16		return distributionInspect, objectNotFoundError{object: "distribution", id: image}
17	}
18
19	if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil {
20		return distributionInspect, err
21	}
22	var headers map[string][]string
23
24	if encodedRegistryAuth != "" {
25		headers = map[string][]string{
26			"X-Registry-Auth": {encodedRegistryAuth},
27		}
28	}
29
30	resp, err := cli.get(ctx, "/distribution/"+image+"/json", url.Values{}, headers)
31	defer ensureReaderClosed(resp)
32	if err != nil {
33		return distributionInspect, err
34	}
35
36	err = json.NewDecoder(resp.body).Decode(&distributionInspect)
37	return distributionInspect, err
38}
39