Fallback obtaining manifest digest to the descriptor
Signed-off-by: Rafael da Fonseca <rsafonseca@gmail.com>
This commit is contained in:
parent
9d38ed78d2
commit
4eb2024493
1 changed files with 9 additions and 7 deletions
|
@ -519,21 +519,23 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis
|
||||||
if resp.StatusCode == http.StatusNotModified {
|
if resp.StatusCode == http.StatusNotModified {
|
||||||
return nil, distribution.ErrManifestNotModified
|
return nil, distribution.ErrManifestNotModified
|
||||||
} else if SuccessStatus(resp.StatusCode) {
|
} 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")
|
mt := resp.Header.Get("Content-Type")
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m, _, err := distribution.UnmarshalManifest(mt, body)
|
m, desc, err := distribution.UnmarshalManifest(mt, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 m, nil
|
||||||
}
|
}
|
||||||
return nil, HandleErrorResponse(resp)
|
return nil, HandleErrorResponse(resp)
|
||||||
|
|
Loading…
Reference in a new issue