Skip to content

Commit 770c6b0

Browse files
committed
compat: RepoTags and RepoDigest return [] and not null
Signed-off-by: Nicola Sella <[email protected]>
1 parent 4030ee6 commit 770c6b0

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
@@ -496,6 +496,15 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
496496
// docker adds sha256: in front of the ID
497497
for _, s := range summaries {
498498
s.ID = "sha256:" + s.ID
499+
// Ensure RepoTags and RepoDigests are empty arrays instead of null for Docker compatibility
500+
// as per https://docs.docker.com/reference/api/engine/version-history/#v143-api-changes
501+
// Relates to https://issues.redhat.com/browse/RUN-2699
502+
if s.RepoTags == nil {
503+
s.RepoTags = []string{}
504+
}
505+
if s.RepoDigests == nil {
506+
s.RepoDigests = []string{}
507+
}
499508
}
500509
}
501510
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+
.[2].RepoTags=[] \
452+
.[2].RepoDigests=[] \
453+
.[2].Id=$(< $IIDFILE)
454+
455+
podman rmi -f $(< $IIDFILE)
456+
rm -f $IIDFILE
457+
443458
# vim: filetype=sh

0 commit comments

Comments
 (0)