From a3156da21ccd830639ff5699c13da82f3062439b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 26 Mar 2018 16:23:24 -0400 Subject: podman exec should handle options --env foo If the user does not specify foo=bar, then the exec code should look for the foo environment variable in its environment and pass it in. This is the way podman run works. Also added tests to make sure this all works. Signed-off-by: Daniel J Walsh Closes: #552 Approved by: mheon --- test/e2e/exec_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 95068a774..c64c8666c 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -59,4 +59,32 @@ var _ = Describe("Podman exec", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + It("podman exec environment test", func() { + setup := podmanTest.RunTopContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", "-l", "--env", "FOO=BAR", "printenv", "FOO"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ := session.GrepString("BAR") + Expect(match).Should(BeTrue()) + + session = podmanTest.Podman([]string{"exec", "-l", "--env", "PATH=/bin", "printenv", "PATH"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ = session.GrepString("/bin") + Expect(match).Should(BeTrue()) + + os.Setenv("FOO", "BAR") + session = podmanTest.Podman([]string{"exec", "-l", "--env", "FOO", "printenv", "FOO"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ = session.GrepString("BAR") + Expect(match).Should(BeTrue()) + os.Unsetenv("FOO") + + }) + }) -- cgit v1.2.3-54-g00ecf