mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
Merge pull request #26276 from inknos/compat-get-images-json-empty-list-repotags
compat: GET /images/json returns [] instead of <none>:<none> in RepoTags and RepoDigest
This commit is contained in:
@ -468,6 +468,15 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
// docker adds sha256: in front of the ID
|
// docker adds sha256: in front of the ID
|
||||||
for _, s := range summaries {
|
for _, s := range summaries {
|
||||||
s.ID = "sha256:" + s.ID
|
s.ID = "sha256:" + s.ID
|
||||||
|
// Ensure RepoTags and RepoDigests are empty arrays instead of null for Docker compatibility
|
||||||
|
// as per https://docs.docker.com/reference/api/engine/version-history/#v143-api-changes
|
||||||
|
// Relates to https://issues.redhat.com/browse/RUN-2699
|
||||||
|
if s.RepoTags == nil {
|
||||||
|
s.RepoTags = []string{}
|
||||||
|
}
|
||||||
|
if s.RepoDigests == nil {
|
||||||
|
s.RepoDigests = []string{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
utils.WriteResponse(w, http.StatusOK, summaries)
|
utils.WriteResponse(w, http.StatusOK, summaries)
|
||||||
|
@ -440,4 +440,19 @@ t GET "libpod/events?stream=false&since=$START" 200 \
|
|||||||
.Actor.Attributes.name="localhost:5000/idonotexist" \
|
.Actor.Attributes.name="localhost:5000/idonotexist" \
|
||||||
.Actor.Attributes.error~".*connection refused"
|
.Actor.Attributes.error~".*connection refused"
|
||||||
|
|
||||||
|
# test empty RepoTags and RepoDigests is an empty array
|
||||||
|
IIDFILE=$(mktemp)
|
||||||
|
podman image build --iidfile $IIDFILE -<<EOF
|
||||||
|
FROM $IMAGE
|
||||||
|
RUN :
|
||||||
|
EOF
|
||||||
|
|
||||||
|
t GET images/json 200 \
|
||||||
|
.[1].RepoTags=[] \
|
||||||
|
.[1].RepoDigests=[] \
|
||||||
|
.[1].Id=$(< $IIDFILE)
|
||||||
|
|
||||||
|
podman rmi -f $(< $IIDFILE)
|
||||||
|
rm -f $IIDFILE
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
Reference in New Issue
Block a user