Merge pull request #4677 from baude/execenvfile

allow exec to read files of environment variables
This commit is contained in:
OpenShift Merge Robot 2019-12-11 21:22:59 +01:00 committed by GitHub
commit f81f15f422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 1 deletions

View File

@ -128,6 +128,7 @@ type ExecValues struct {
PodmanCommand PodmanCommand
DetachKeys string DetachKeys string
Env []string Env []string
EnvFile []string
Privileged bool Privileged bool
Interactive bool Interactive bool
Tty bool Tty bool

View File

@ -40,6 +40,7 @@ func init() {
// priority // priority
execCommand.DetachKeys = "" execCommand.DetachKeys = ""
flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables") flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables")
flags.StringSliceVar(&execCommand.EnvFile, "env-file", []string{}, "Read in a file of environment variables")
flags.BoolVarP(&execCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached") flags.BoolVarP(&execCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
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")
@ -48,6 +49,7 @@ func init() {
flags.IntVar(&execCommand.PreserveFDs, "preserve-fds", 0, "Pass N additional file descriptors to the container") flags.IntVar(&execCommand.PreserveFDs, "preserve-fds", 0, "Pass N additional file descriptors to the container")
flags.StringVarP(&execCommand.Workdir, "workdir", "w", "", "Working directory inside the container") flags.StringVarP(&execCommand.Workdir, "workdir", "w", "", "Working directory inside the container")
markFlagHiddenForRemoteClient("env-file", flags)
markFlagHiddenForRemoteClient("latest", flags) markFlagHiddenForRemoteClient("latest", flags)
markFlagHiddenForRemoteClient("preserve-fds", flags) markFlagHiddenForRemoteClient("preserve-fds", flags)
} }

View File

@ -1359,6 +1359,7 @@ _podman_exec() {
--detach-keys --detach-keys
-e -e
--env --env
--env-file
--user --user
-u -u
--workdir --workdir

View File

@ -22,6 +22,10 @@ Specify the key sequence for detaching a container. Format is a single character
You may specify arbitrary environment variables that are available for the You may specify arbitrary environment variables that are available for the
command to be executed. command to be executed.
**--env-file**=*file*
Read in a line delimited file of environment variables.
**--interactive**, **-i**=*true|false* **--interactive**, **-i**=*true|false*
When set to true, keep stdin open even if not attached. The default is *false*. When set to true, keep stdin open even if not attached. The default is *false*.

View File

@ -1024,7 +1024,7 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
// Validate given environment variables // Validate given environment variables
env := map[string]string{} env := map[string]string{}
if err := parse.ReadKVStrings(env, []string{}, cli.Env); err != nil { if err := parse.ReadKVStrings(env, cli.EnvFile, cli.Env); err != nil {
return ec, errors.Wrapf(err, "unable to process environment variables") return ec, errors.Wrapf(err, "unable to process environment variables")
} }