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)
| 953 | // fetchManifest fetches a manifest for (the repo of ref) + tagOrDigest. |
| 954 | // The caller is responsible for ensuring tagOrDigest uses the expected format. |
| 955 | func (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 |
no test coverage detected