Skip to content

Commit 3ef3365

Browse files
committed
compat: RepoTags and RepoDigest return [] and not null
Signed-off-by: Nicola Sella <[email protected]>
1 parent 20d5b78 commit 3ef3365

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pkg/api/handlers/compat/images.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
468468
// docker adds sha256: in front of the ID
469469
for _, s := range summaries {
470470
s.ID = "sha256:" + s.ID
471+
// Ensure RepoTags and RepoDigests are empty arrays instead of null for Docker compatibility
472+
// as per https://docs.docker.com/reference/api/engine/version-history/#v143-api-changes
473+
// Relates to https://issues.redhat.com/browse/RUN-2699
474+
if s.RepoTags == nil {
475+
s.RepoTags = []string{}
476+
}
477+
if s.RepoDigests == nil {
478+
s.RepoDigests = []string{}
479+
}
471480
}
472481
}
473482
utils.WriteResponse(w, http.StatusOK, summaries)

test/apiv2/10-images.at

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,19 @@ t GET "libpod/events?stream=false&since=$START" 200 \
440440
.Actor.Attributes.name="localhost:5000/idonotexist" \
441441
.Actor.Attributes.error~".*connection refused"
442442

443+
# test empty RepoTags and RepoDigests is an empty array
444+
IIDFILE=$(mktemp)
445+
podman image build --iidfile $IIDFILE -<<EOF
446+
FROM $IMAGE
447+
RUN :
448+
EOF
449+
450+
t GET images/json 200 \
451+
.[1].RepoTags=[] \
452+
.[1].RepoDigests=[] \
453+
.[1].Id=$(< $IIDFILE)
454+
455+
podman rmi -f $(< $IIDFILE)
456+
rm -f $IIDFILE
457+
443458
# vim: filetype=sh

0 commit comments

Comments
 (0)