MCPcopy Create free account
hub / github.com/containers/image / fetchManifest

Method fetchManifest

docker/docker_client.go:955–975  ·  view source on GitHub ↗

fetchManifest fetches a manifest for (the repo of ref) + tagOrDigest. The caller is responsible for ensuring tagOrDigest uses the expected format.

(ctx context.Context, ref dockerReference, tagOrDigest string)

Source from the content-addressed store, hash-verified

953// fetchManifest fetches a manifest for (the repo of ref) + tagOrDigest.
954// The caller is responsible for ensuring tagOrDigest uses the expected format.
955func (c *dockerClient) fetchManifest(ctx context.Context, ref dockerReference, tagOrDigest string) ([]byte, string, error) {
956 path := fmt.Sprintf(manifestPath, reference.Path(ref.ref), tagOrDigest)
957 headers := map[string][]string{
958 "Accept": manifest.DefaultRequestedManifestMIMETypes,
959 }
960 res, err := c.makeRequest(ctx, http.MethodGet, path, headers, nil, v2Auth, nil)
961 if err != nil {
962 return nil, "", err
963 }
964 logrus.Debugf("Content-Type from manifest GET is %q", res.Header.Get("Content-Type"))
965 defer res.Body.Close()
966 if res.StatusCode != http.StatusOK {
967 return nil, "", fmt.Errorf("reading manifest %s in %s: %w", tagOrDigest, ref.ref.Name(), registryHTTPResponseToError(res))
968 }
969
970 manblob, err := iolimits.ReadAtMost(res.Body, iolimits.MaxManifestBodySize)
971 if err != nil {
972 return nil, "", err
973 }
974 return manblob, simplifyContentType(res.Header.Get("Content-Type")), nil
975}
976
977// getExternalBlob returns the reader of the first available blob URL from urls, which must not be empty.
978// This function can return nil reader when no url is supported by this function. In this case, the caller

Callers 1

Calls 8

makeRequestMethod · 0.95
PathFunction · 0.92
ReadAtMostFunction · 0.92
simplifyContentTypeFunction · 0.85
GetMethod · 0.80
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected