mirror of
https://github.com/containers/podman.git
synced 2025-12-08 14:48:48 +08:00
run,create: add support for --env-merge for preprocessing vars
Allow end users to preprocess default environment variables before
injecting them into container using `--env-merge`
Usage
```
podman run -it --rm --env-merge some=${some}-edit --env-merge
some2=${some2}-edit2 myimage sh
```
Closes: https://github.com/containers/podman/issues/15288
Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
@@ -82,6 +82,17 @@ var _ = Describe("Podman run", func() {
|
||||
Expect(session.OutputToString()).To(ContainSubstring("HOSTNAME"))
|
||||
})
|
||||
|
||||
It("podman run with --env-merge", func() {
|
||||
dockerfile := `FROM quay.io/libpod/alpine:latest
|
||||
ENV hello=world
|
||||
`
|
||||
podmanTest.BuildImage(dockerfile, "test", "false")
|
||||
session := podmanTest.Podman([]string{"run", "--rm", "--env-merge", "hello=${hello}-earth", "test", "env"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("world-earth"))
|
||||
})
|
||||
|
||||
It("podman run --env-host environment test", func() {
|
||||
env := append(os.Environ(), "FOO=BAR")
|
||||
session := podmanTest.PodmanAsUser([]string{"run", "--rm", "--env-host", ALPINE, "/bin/printenv", "FOO"}, 0, 0, "", env)
|
||||
|
||||
Reference in New Issue
Block a user