From 6b3d4abb07bd15f6ca2c2f1dc007c325b9cc0dc4 Mon Sep 17 00:00:00 2001
From: Daniel J Walsh <dwalsh@redhat.com>
Date: Tue, 16 Apr 2019 06:26:47 -0400
Subject: Fix podman command --change CMD

Currently in Docker if you commit with --change 'CMD a b c'
The command that gets added is

[/bin/sh -c "a b c"]

If you commit --change 'CMD ["a","b","c"]'

You get
[a b c]

This patch set makes podman match this behaviour.

Similar change required for Entrypoint.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
---
 test/e2e/commit_test.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'test/e2e')

diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go
index 93e1ea7af..3ece4887e 100644
--- a/test/e2e/commit_test.go
+++ b/test/e2e/commit_test.go
@@ -117,6 +117,31 @@ var _ = Describe("Podman commit", func() {
 		Expect(foundBlue).To(Equal(true))
 	})
 
+	It("podman commit container with change CMD flag", func() {
+		test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
+		test.WaitWithDefaultTimeout()
+		Expect(test.ExitCode()).To(Equal(0))
+		Expect(podmanTest.NumberOfContainers()).To(Equal(1))
+
+		session := podmanTest.Podman([]string{"commit", "--change", "CMD a b c", "test1", "foobar.com/test1-image:latest"})
+		session.WaitWithDefaultTimeout()
+		Expect(session.ExitCode()).To(Equal(0))
+
+		session = podmanTest.Podman([]string{"inspect", "--format", "{{.Config.Cmd}}", "foobar.com/test1-image:latest"})
+		session.WaitWithDefaultTimeout()
+		Expect(session.ExitCode()).To(Equal(0))
+		Expect(session.OutputToString()).To(ContainSubstring("sh -c a b c"))
+
+		session = podmanTest.Podman([]string{"commit", "--change", "CMD=[\"a\",\"b\",\"c\"]", "test1", "foobar.com/test1-image:latest"})
+		session.WaitWithDefaultTimeout()
+		Expect(session.ExitCode()).To(Equal(0))
+
+		session = podmanTest.Podman([]string{"inspect", "--format", "{{.Config.Cmd}}", "foobar.com/test1-image:latest"})
+		session.WaitWithDefaultTimeout()
+		Expect(session.ExitCode()).To(Equal(0))
+		Expect(session.OutputToString()).To(Not(ContainSubstring("sh -c")))
+	})
+
 	It("podman commit container with pause flag", func() {
 		_, ec, _ := podmanTest.RunLsContainer("test1")
 		Expect(ec).To(Equal(0))
-- 
cgit v1.2.3-54-g00ecf