Specify format to buildah before commit

If user specifies commit --format, we were not setting it before
commit, this caused warning messages that made no sense to be
printed that made no sense.

Fixes: https://github.com/containers/podman/issues/17773

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-04-14 07:49:13 -04:00
parent e74a4086ec
commit 81621ce8af
2 changed files with 14 additions and 0 deletions

View File

@ -68,6 +68,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
PreferredManifestType: options.PreferredManifestType,
}
importBuilder, err := buildah.ImportBuilder(ctx, c.runtime.store, builderOptions)
importBuilder.Format = options.PreferredManifestType
if err != nil {
return nil, err
}

View File

@ -309,4 +309,17 @@ Deleted: $pauseID"
is "$output" "" "Should print no output"
}
@test "podman images - commit docker with comment" {
run_podman run --name my-container -itd $IMAGE sleep 1d
run_podman 125 commit -m comment my-container my-test-image
assert "$output" == "Error: messages are only compatible with the docker image format (-f docker)" "podman should fail unless docker format"
run_podman commit my-container --format docker -m comment my-test-image
run_podman commit -q my-container --format docker -m comment my-test-image
assert "$output" =~ "^[0-9a-f]{64}\$" \
"Output is a commit ID, no warnings or other output"
run_podman rmi my-test-image
run_podman rm my-container --force -t 0
}
# vim: filetype=sh