From 4192298be3e55207ca983c21f357029df9765c56 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Wed, 1 Jul 2020 10:43:44 -0400 Subject: Set engine env from common config Set the env that is used by Podman. related issue containers/common#31 Signed-off-by: Qi Wang --- cmd/podman/root.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd') diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 45ca48c39..3bb45f806 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -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 { -- cgit v1.2.3-54-g00ecf