Skip to content

Commit

Permalink
Merge pull request #6790 from QiWang19/set_engine_env
Browse files Browse the repository at this point in the history
Set engine env from common config
  • Loading branch information
openshift-merge-robot authored Jul 6, 2020
2 parents 262843e + 4192298 commit 4bdc119
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
return err
}

for _, env := range cfg.Engine.Env {
splitEnv := strings.SplitN(env, "=", 2)
if len(splitEnv) != 2 {
return fmt.Errorf("invalid environment variable for engine %s, valid configuration is KEY=value pair", env)
}
// skip if the env is already defined
if _, ok := os.LookupEnv(splitEnv[0]); ok {
logrus.Debugf("environment variable %s is already defined, skip the settings from containers.conf", splitEnv[0])
continue
}
if err := os.Setenv(splitEnv[0], splitEnv[1]); err != nil {
return err
}
}

if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(cfg.CPUProfile)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ NOTE --tmpdir is not used for the temporary storage of downloaded images. Use t

Print the version

## Environment Variables

Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands.

## Exit Status

The exit code from `podman` gives information about why the container
Expand Down

0 comments on commit 4bdc119

Please sign in to comment.