in ecr/fetcher.go [144:169]
func (f *ecrFetcher) fetchLayerURL(ctx context.Context, desc ocispec.Descriptor, downloadURL string) (io.ReadCloser, error) {
req, err := http.NewRequest(http.MethodGet, downloadURL, nil)
if err != nil {
log.G(ctx).
WithError(err).
WithField("url", downloadURL).
Error("ecr.fetcher.layer.url: failed to create HTTP request")
return nil, err
}
log.G(ctx).WithField("url", downloadURL).Debug("ecr.fetcher.layer.url")
req.Header.Set("Accept", strings.Join([]string{desc.MediaType, `*`}, ", "))
resp, err := f.doRequest(ctx, req)
if err != nil {
return nil, err
}
if resp.StatusCode > 299 {
resp.Body.Close()
if resp.StatusCode == http.StatusNotFound {
return nil, errors.Wrapf(errdefs.ErrNotFound, "content at %v not found", downloadURL)
}
return nil, errors.Errorf("ecr.fetcher.layer.url: unexpected status code %v: %v", downloadURL, resp.Status)
}
log.G(ctx).WithField("desc", desc).Debug("ecr.fetcher.layer.url: returning body")
return resp.Body, nil
}