compat API: push: report size of manifest

We don't yet have a local registry running in the APIv2 tests.
Tested manually.

[NO NEW TESTS NEEDED]

Fixes: https://github.com/containers/podman/issues/12468

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-12-01 13:19:04 -05:00
committed by Valentin Rothberg
parent 078e633294
commit 8d6d9df407

View File

@ -74,10 +74,16 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
return return
} }
imageName = possiblyNormalizedName imageName = possiblyNormalizedName
if _, _, err := runtime.LibimageRuntime().LookupImage(possiblyNormalizedName, nil); err != nil { localImage, _, err := runtime.LibimageRuntime().LookupImage(possiblyNormalizedName, nil)
if err != nil {
utils.ImageNotFound(w, imageName, errors.Wrapf(err, "failed to find image %s", imageName)) utils.ImageNotFound(w, imageName, errors.Wrapf(err, "failed to find image %s", imageName))
return return
} }
rawManifest, _, err := localImage.Manifest(r.Context())
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, err)
return
}
authconf, authfile, key, err := auth.GetCredentials(r) authconf, authfile, key, err := auth.GetCredentials(r)
if err != nil { if err != nil {
@ -196,7 +202,7 @@ loop: // break out of for/select infinite loop
if tag == "" { if tag == "" {
tag = "latest" tag = "latest"
} }
report.Status = fmt.Sprintf("%s: digest: %s", tag, string(digestBytes)) report.Status = fmt.Sprintf("%s: digest: %s size: %d", tag, string(digestBytes), len(rawManifest))
if err := enc.Encode(report); err != nil { if err := enc.Encode(report); err != nil {
logrus.Warnf("Failed to json encode error %q", err.Error()) logrus.Warnf("Failed to json encode error %q", err.Error())
} }