podman: do not split --env on comma

if --env "a=b,c" is used, do not split into a=b and c=.

Closes: https://github.com/containers/libpod/issues/2712

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-03-20 12:45:04 +01:00
parent c230f0c693
commit a53c768409
4 changed files with 5 additions and 5 deletions

View File

@ -264,7 +264,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"entrypoint", "", "entrypoint", "",
"Overwrite the default ENTRYPOINT of the image", "Overwrite the default ENTRYPOINT of the image",
) )
createFlags.StringSliceP( createFlags.StringArrayP(
"env", "e", []string{}, "env", "e", []string{},
"Set environment variables in container", "Set environment variables in container",
) )

View File

@ -41,7 +41,7 @@ func init() {
execCommand.SetUsageTemplate(UsageTemplate()) execCommand.SetUsageTemplate(UsageTemplate())
flags := execCommand.Flags() flags := execCommand.Flags()
flags.SetInterspersed(false) flags.SetInterspersed(false)
flags.StringSliceVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables") flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables")
flags.BoolVarP(&execCommand.Interfactive, "interactive", "i", false, "Not supported. All exec commands are interactive by default") flags.BoolVarP(&execCommand.Interfactive, "interactive", "i", false, "Not supported. All exec commands are interactive by default")
flags.BoolVarP(&execCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.BoolVarP(&execCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&execCommand.Privileged, "privileged", false, "Give the process extended Linux capabilities inside the container. The default is false") flags.BoolVar(&execCommand.Privileged, "privileged", false, "Give the process extended Linux capabilities inside the container. The default is false")

View File

@ -499,7 +499,7 @@ func ParseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l
} }
} }
} }
if err := parse.ReadKVStrings(env, c.StringSlice("env-file"), c.StringSlice("env")); err != nil { if err := parse.ReadKVStrings(env, c.StringSlice("env-file"), c.StringArray("env")); err != nil {
return nil, errors.Wrapf(err, "unable to process environment variables") return nil, errors.Wrapf(err, "unable to process environment variables")
} }

View File

@ -152,10 +152,10 @@ var _ = Describe("Podman run", func() {
}) })
It("podman run environment test", func() { It("podman run environment test", func() {
session := podmanTest.Podman([]string{"run", "--rm", "--env", "FOO=BAR", ALPINE, "printenv", "FOO"}) session := podmanTest.Podman([]string{"run", "--rm", "--env", "FOO=BAR,BAZ", ALPINE, "printenv", "FOO"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
match, _ := session.GrepString("BAR") match, _ := session.GrepString("BAR,BAZ")
Expect(match).Should(BeTrue()) Expect(match).Should(BeTrue())
session = podmanTest.Podman([]string{"run", "--rm", "--env", "PATH=/bin", ALPINE, "printenv", "PATH"}) session = podmanTest.Podman([]string{"run", "--rm", "--env", "PATH=/bin", ALPINE, "printenv", "PATH"})