mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00

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>
31 lines
937 B
Plaintext
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
|