2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2017-04-05 18:43:17 -04:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2017-04-05 18:43:17 -04:00
|
|
|
"encoding/json"
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
registrytypes "github.com/docker/docker/api/types/registry"
|
|
|
|
)
|
|
|
|
|
2021-02-16 10:07:44 -05:00
|
|
|
// DistributionInspect returns the image digest with the full manifest.
|
2017-04-05 18:43:17 -04:00
|
|
|
func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) {
|
2017-06-07 12:09:07 -04:00
|
|
|
// Contact the registry to retrieve digest and platform information
|
|
|
|
var distributionInspect registrytypes.DistributionInspect
|
2018-01-30 07:35:22 -05:00
|
|
|
if image == "" {
|
|
|
|
return distributionInspect, objectNotFoundError{object: "distribution", id: image}
|
|
|
|
}
|
2017-06-07 12:09:07 -04:00
|
|
|
|
|
|
|
if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil {
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|
2017-04-05 18:43:17 -04:00
|
|
|
var headers map[string][]string
|
|
|
|
|
|
|
|
if encodedRegistryAuth != "" {
|
|
|
|
headers = map[string][]string{
|
|
|
|
"X-Registry-Auth": {encodedRegistryAuth},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := cli.get(ctx, "/distribution/"+image+"/json", url.Values{}, headers)
|
2019-02-11 07:26:12 -05:00
|
|
|
defer ensureReaderClosed(resp)
|
2017-04-05 18:43:17 -04:00
|
|
|
if err != nil {
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&distributionInspect)
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|