Files
podman/test/apiv2/14-commit.at
Nalin Dahyabhai 426db6fcc1 Accept a config blob alongside the "changes" slice when committing
When committing containers to create new images, accept a container
config blob being passed in the body of the API request by adding a
Config field to our API structures.  Populate it from the body of
requests that we receive, and use its contents as the body of requests
that we make.

Make the libpod commit endpoint split changes values at newlines, just
like the compat endpoint does.

Pass both the config blob and the "changes" slice to buildah's Commit()
API, so that it can handle cases where they overlap or conflict.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-11-30 09:00:52 -05:00

31 lines
937 B
Plaintext

# Create a container for testing the container initializing later
podman create -t -i --name myctr $IMAGE ls
config=$(mktemp -t config.XXXXXXXXXX.json)
cat > "$config" <<- EOF
{
"Entrypoint": ["/bin/crash"],
"Cmd": ["and", "burn"],
"Labels": {"for": "ever", "and": "ever"}
}
EOF
# Create a new image based on the container
t POST 'libpod/commit?container=myctr&repo=nativeimage&tag=1' $config 200
# Check some things
t GET libpod/images/nativeimage:1/json 200 ".Config.Cmd=$(jq .Cmd $config)" ".Config.Entrypoint=$(jq .Entrypoint $config)"
# Create a new image based on the container
t POST 'commit?container=myctr&repo=compatimage&tag=1' $config 201
# Check some things
t GET images/compatimage:1/json 200 ".Config.Cmd=$(jq .Cmd $config)" ".Config.Entrypoint=$(jq .Entrypoint $config)"
# Clean up
t DELETE containers/myctr 204
t DELETE images/nativeimage:1 200
t DELETE images/compatimage:1 200
rm -f "$config"
unset config