From 6411f57e789ecef322c120d34ad634495e54d257 Mon Sep 17 00:00:00 2001 From: Josh Patterson Date: Wed, 17 Aug 2022 11:26:17 -0400 Subject: [PATCH 1/2] api: return imageID instead of imageName, for "Image" when Podman API is queried Signed-off-by: Josh Patterson --- pkg/api/handlers/compat/containers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index ae063dc9fd..35681cb367 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -407,7 +407,7 @@ func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *t } func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, error) { - _, imageName := l.Image() + imageID, imageName := l.Image() inspect, err := l.Inspect(sz) if err != nil { return nil, err @@ -487,7 +487,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, Path: inspect.Path, Args: inspect.Args, State: &state, - Image: imageName, + Image: "sha256:" + imageID, ResolvConfPath: inspect.ResolvConfPath, HostnamePath: inspect.HostnamePath, HostsPath: inspect.HostsPath, From 08af95f63576af0c443fdef9d3ba6ba12a0c0dbc Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Mon, 29 Aug 2022 14:10:33 -0400 Subject: [PATCH 2/2] updated apiv2 tests to reflect hash compat fix Signed-off-by: Jason Ertel --- test/apiv2/20-containers.at | 4 +++- test/apiv2/70-short-names.at | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index ac3626cf11..29b641853c 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -309,7 +309,9 @@ t POST containers/create Image=${MultiTagName} 201 \ .Id~[0-9a-f]\\{64\\} cid=$(jq -r '.Id' <<<"$output") t GET containers/$cid/json 200 \ - .Image=${MultiTagName} + .Config.Image=${MultiTagName} \ + .Image~sha256:[0-9a-f]\\{64\\} + t DELETE containers/$cid 204 t DELETE images/${MultiTagName} 200 # vim: filetype=sh diff --git a/test/apiv2/70-short-names.at b/test/apiv2/70-short-names.at index bd7f8e7bd6..643cbc25b6 100644 --- a/test/apiv2/70-short-names.at +++ b/test/apiv2/70-short-names.at @@ -9,7 +9,7 @@ t POST "images/create?fromImage=quay.io/libpod/alpine:latest" 200 .error~null .s # 14291 - let a short-name resolve to a *local* non Docker-Hub image. t POST containers/create Image=alpine 201 .Id~[0-9a-f]\\{64\\} cid=$(jq -r '.Id' <<<"$output") -t GET containers/$cid/json 200 .Image="quay.io/libpod/alpine:latest" +t GET containers/$cid/json 200 .Config.Image="quay.io/libpod/alpine:latest" .Image~sha256:[0-9a-f]\\{64\\} podman rm -f $cid ########## TAG