From 81621ce8afbec33e8aabff1095eb6cbb2a5a54e6 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 14 Apr 2023 07:49:13 -0400 Subject: [PATCH] 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 --- libpod/container_commit.go | 1 + test/system/010-images.bats | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/libpod/container_commit.go b/libpod/container_commit.go index df0a77bc3d..d4db1e447b 100644 --- a/libpod/container_commit.go +++ b/libpod/container_commit.go @@ -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 } diff --git a/test/system/010-images.bats b/test/system/010-images.bats index d556ec5579..70184b6a1a 100644 --- a/test/system/010-images.bats +++ b/test/system/010-images.bats @@ -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