Skip to content

Commit

Permalink
compat API: /images/json prefix image id with sha256
Browse files Browse the repository at this point in the history
Docker adds the `sha256:` prefix to the image ID, so our compat endpoint
has to do this as well.

Fixes containers#11623

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 20, 2021
1 parent ddb3844 commit 5242030
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/api/handlers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions test/apiv2/python/rest_api/test_v2_0_0_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def test_list(self):
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)
Expand Down Expand Up @@ -59,6 +62,8 @@ def test_inspect(self):
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")
Expand Down

0 comments on commit 5242030

Please sign in to comment.