summaryrefslogtreecommitdiff
path: root/cmd/podman/shared
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-04-14 16:27:52 -0400
committerPeter Hunt <pehunt@redhat.com>2019-04-14 16:27:52 -0400
commite61838bc3b25faba708856e2208aa2026381a341 (patch)
treebf31d22dd96ecc0688b8dc5301f390dc9a77c456 /cmd/podman/shared
parent167ce59416f6e03f4477269e33e9e5cf5b700a86 (diff)
downloadpodman-e61838bc3b25faba708856e2208aa2026381a341.tar.gz
podman-e61838bc3b25faba708856e2208aa2026381a341.tar.bz2
podman-e61838bc3b25faba708856e2208aa2026381a341.zip
Incorporate image and default environment variables in play kube
Also put Environment variable parsing from image data into a helper function Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'cmd/podman/shared')
-rw-r--r--cmd/podman/shared/create.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index d694027db..a1c096853 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -489,17 +489,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
}
// ENVIRONMENT VARIABLES
- env := defaultEnvVariables
- if data != nil {
- for _, e := range data.Config.Env {
- split := strings.SplitN(e, "=", 2)
- if len(split) > 1 {
- env[split[0]] = split[1]
- } else {
- env[split[0]] = ""
- }
- }
- }
+ env := EnvVariablesFromData(data)
if err := parse.ReadKVStrings(env, c.StringSlice("env-file"), c.StringArray("env")); err != nil {
return nil, errors.Wrapf(err, "unable to process environment variables")
}
@@ -781,6 +771,23 @@ var defaultEnvVariables = map[string]string{
"TERM": "xterm",
}
+// EnvVariablesFromData gets sets the default environment variables
+// for containers, and reads the variables from the image data, if present.
+func EnvVariablesFromData(data *inspect.ImageData) map[string]string {
+ env := defaultEnvVariables
+ if data != nil {
+ for _, e := range data.Config.Env {
+ split := strings.SplitN(e, "=", 2)
+ if len(split) > 1 {
+ env[split[0]] = split[1]
+ } else {
+ env[split[0]] = ""
+ }
+ }
+ }
+ return env
+}
+
func makeHealthCheckFromCli(c *GenericCLIResults) (*manifest.Schema2HealthConfig, error) {
inCommand := c.String("healthcheck-command")
inInterval := c.String("healthcheck-interval")