summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-09-20 13:43:30 +0200
committerMatthew Heon <matthew.heon@pm.me>2021-09-22 16:23:53 -0400
commit863ea75c4f29add42bfff517974c8b4f36925334 (patch)
treead2dcff85fa22ff66ae34566c8ebafee9cb8f5e0
parentc66db2b704cf5c98bdf1ecc337aeb5550e6ecd70 (diff)
downloadpodman-863ea75c4f29add42bfff517974c8b4f36925334.tar.gz
podman-863ea75c4f29add42bfff517974c8b4f36925334.tar.bz2
podman-863ea75c4f29add42bfff517974c8b4f36925334.zip
compat API: /images/json prefix image id with sha256
Docker adds the `sha256:` prefix to the image ID, so our compat endpoint has to do this as well. Fixes #11623 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--pkg/api/handlers/types.go3
-rw-r--r--test/apiv2/python/rest_api/test_v2_0_0_image.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go
index b82c586ea..fedab3bb3 100644
--- a/pkg/api/handlers/types.go
+++ b/pkg/api/handlers/types.go
@@ -183,7 +183,8 @@ func ImageToImageSummary(l *libimage.Image) (*entities.ImageSummary, error) {
}
is := entities.ImageSummary{
- ID: l.ID(),
+ // docker adds sha256: in front of the ID
+ ID: "sha256:" + l.ID(),
ParentId: imageData.Parent,
RepoTags: imageData.RepoTags,
RepoDigests: imageData.RepoDigests,
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_image.py b/test/apiv2/python/rest_api/test_v2_0_0_image.py
index bcacaa935..58d03b149 100644
--- a/test/apiv2/python/rest_api/test_v2_0_0_image.py
+++ b/test/apiv2/python/rest_api/test_v2_0_0_image.py
@@ -32,6 +32,9 @@ class ImageTestCase(APITestCase):
for k in required_keys:
self.assertIn(k, item)
+ # Id should be prefixed with sha256: (#11645)
+ self.assertIn("sha256:",item['Id'])
+
def test_inspect(self):
r = requests.get(self.podman_url + "/v1.40/images/alpine/json")
self.assertEqual(r.status_code, 200, r.text)
@@ -59,6 +62,8 @@ class ImageTestCase(APITestCase):
for item in required_keys:
self.assertIn(item, image)
_ = parse(image["Created"])
+ # Id should be prefixed with sha256: (#11645)
+ self.assertIn("sha256:",image['Id'])
def test_delete(self):
r = requests.delete(self.podman_url + "/v1.40/images/alpine?force=true")