2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2017-04-05 22:43:17 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2017-04-05 22:43:17 +00:00
|
|
|
"encoding/json"
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
registrytypes "github.com/docker/docker/api/types/registry"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DistributionInspect returns the image digest with full Manifest
|
|
|
|
func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) {
|
2017-06-07 16:09:07 +00:00
|
|
|
// Contact the registry to retrieve digest and platform information
|
|
|
|
var distributionInspect registrytypes.DistributionInspect
|
2018-01-30 12:35:22 +00:00
|
|
|
if image == "" {
|
|
|
|
return distributionInspect, objectNotFoundError{object: "distribution", id: image}
|
|
|
|
}
|
2017-06-07 16:09:07 +00:00
|
|
|
|
|
|
|
if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil {
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|
2017-04-05 22:43:17 +00: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 12:26:12 +00:00
|
|
|
defer ensureReaderClosed(resp)
|
2017-04-05 22:43:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&distributionInspect)
|
|
|
|
return distributionInspect, err
|
|
|
|
}
|