Fallback obtaining manifest digest to the descriptor

Signed-off-by: Rafael da Fonseca <rsafonseca@gmail.com>
This commit is contained in:
Rafael da Fonseca 2022-11-11 10:12:52 +00:00
parent 9d38ed78d2
commit 4eb2024493

View file

@ -519,21 +519,23 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis
if resp.StatusCode == http.StatusNotModified {
return nil, distribution.ErrManifestNotModified
} else if SuccessStatus(resp.StatusCode) {
if contentDgst != nil {
dgst, err := digest.Parse(resp.Header.Get("Docker-Content-Digest"))
if err == nil {
*contentDgst = dgst
}
}
mt := resp.Header.Get("Content-Type")
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
m, _, err := distribution.UnmarshalManifest(mt, body)
m, desc, err := distribution.UnmarshalManifest(mt, body)
if err != nil {
return nil, err
}
if contentDgst != nil {
dgst, err := digest.Parse(resp.Header.Get("Docker-Content-Digest"))
if err == nil {
*contentDgst = dgst
} else {
*contentDgst = desc.Digest
}
}
return m, nil
}
return nil, HandleErrorResponse(resp)