mirror of
https://github.com/containers/podman.git
synced 2025-05-26 03:47:53 +08:00
Add sha256: to images history id for docker compatibility
Fixes: https://github.com/containers/podman/issues/17762 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -33,13 +33,17 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
allHistory := make([]handlers.HistoryResponse, 0, len(history))
|
allHistory := make([]handlers.HistoryResponse, 0, len(history))
|
||||||
for _, h := range history {
|
for _, h := range history {
|
||||||
l := handlers.HistoryResponse{
|
l := handlers.HistoryResponse{
|
||||||
ID: h.ID,
|
|
||||||
Created: h.Created.Unix(),
|
Created: h.Created.Unix(),
|
||||||
CreatedBy: h.CreatedBy,
|
CreatedBy: h.CreatedBy,
|
||||||
Tags: h.Tags,
|
Tags: h.Tags,
|
||||||
Size: h.Size,
|
Size: h.Size,
|
||||||
Comment: h.Comment,
|
Comment: h.Comment,
|
||||||
}
|
}
|
||||||
|
if utils.IsLibpodRequest(r) {
|
||||||
|
l.ID = h.ID
|
||||||
|
} else {
|
||||||
|
l.ID = "sha256:" + h.ID
|
||||||
|
}
|
||||||
allHistory = append(allHistory, l)
|
allHistory = append(allHistory, l)
|
||||||
}
|
}
|
||||||
utils.WriteResponse(w, http.StatusOK, allHistory)
|
utils.WriteResponse(w, http.StatusOK, allHistory)
|
||||||
|
@ -78,6 +78,15 @@ for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do
|
|||||||
.[0].Comment=
|
.[0].Comment=
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do
|
||||||
|
t GET images/$i/history 200 \
|
||||||
|
.[0].Id="sha256:"$iid \
|
||||||
|
.[0].Created~[0-9]\\{10\\} \
|
||||||
|
.[0].Tags=null \
|
||||||
|
.[0].Size=0 \
|
||||||
|
.[0].Comment=
|
||||||
|
done
|
||||||
|
|
||||||
# Export an image on the local
|
# Export an image on the local
|
||||||
t GET libpod/images/nonesuch/get 404
|
t GET libpod/images/nonesuch/get 404
|
||||||
t GET libpod/images/$iid/get?format=foo 500
|
t GET libpod/images/$iid/get?format=foo 500
|
||||||
|
@ -70,12 +70,11 @@ class TestImages(common.DockerTestCase):
|
|||||||
"""Image history"""
|
"""Image history"""
|
||||||
img = self.docker.images.get(constant.ALPINE)
|
img = self.docker.images.get(constant.ALPINE)
|
||||||
history = img.history()
|
history = img.history()
|
||||||
image_id = img.id[7:] if img.id.startswith("sha256:") else img.id
|
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
for change in history:
|
for change in history:
|
||||||
found |= image_id in change.values()
|
found |= img.id in change.values()
|
||||||
self.assertTrue(found, f"image id {image_id} not found in history")
|
self.assertTrue(found, f"image id {img.id} not found in history")
|
||||||
|
|
||||||
def test_get_image_exists_not(self):
|
def test_get_image_exists_not(self):
|
||||||
"""Negative test for get image"""
|
"""Negative test for get image"""
|
||||||
|
Reference in New Issue
Block a user