From c674d3cc756742d2987d6f392f502e39673a5044 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 18 Jan 2022 16:05:35 -0500 Subject: Handle changes in docker compat mode Fixes: https://github.com/containers/podman/issues/12830 Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images.go | 4 +++- test/apiv2/20-containers.at | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 97fa4ddad..23a9b12a3 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -138,7 +138,9 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) { options.Message = query.Comment options.Author = query.Author options.Pause = query.Pause - options.Changes = strings.Fields(query.Changes) + if query.Changes != "" { + options.Changes = strings.Split(query.Changes, ",") + } ctr, err := runtime.LookupContainer(query.Container) if err != nil { utils.Error(w, "Something went wrong.", http.StatusNotFound, err) diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index e6d49ac25..5f926ccc1 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -408,3 +408,29 @@ t GET containers/$cid/json 200 \ .HostConfig.Binds[0]~/tmp:/mnt:.* \ t DELETE containers/$cid?v=true 204 + +# test apiv2 create/commit +t POST containers/create \ + Image=$IMAGE \ + Entrypoint='["echo"]' \ + Cmd='["param1","param2"]' \ + 201 \ + .Id~[0-9a-f]\\{64\\} +cid=$(jq -r '.Id' <<<"$output") + +# No such container +t POST "commit?container=nonesuch" 404 + +cparam="repo=newrepo&tag=v3&comment=abcd&author=eric" +cparam="$cparam&format=docker&changes=CMD=/bin/bar,EXPOSE=9090" +t POST "commit?container=${cid:0:12}&$cparam" 201 \ + .Id~[0-9a-f]\\{64\\} +iid=$(jq -r '.Id' <<<"$output") +t GET images/$iid/json 200 \ + .RepoTags[0]=docker.io/library/newrepo:v3 \ + .Config.ExposedPorts~.*"9090/tcp" \ + .Config.Cmd~.*"/bin/bar" \ + .Comment="abcd" + +t DELETE containers/$cid 204 +t DELETE images/docker.io/library/newrepo:v3?force=false 200 -- cgit v1.2.3-54-g00ecf