Fix unset env bug for v3 compose

This commit is contained in:
Hang Yan
2018-02-08 15:12:16 +08:00
parent ed9246d537
commit 0ef015d3da
4 changed files with 114 additions and 1 deletions
+12 -1
View File
@@ -319,8 +319,19 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
// Gather the environment values
// DockerCompose uses map[string]*string while we use []string
// So let's convert that using this hack
// Note: unset env pick up the env value on host if exist
for name, value := range composeServiceConfig.Environment {
env := kobject.EnvVar{Name: name, Value: *value}
var env kobject.EnvVar
if value != nil {
env = kobject.EnvVar{Name: name, Value: *value}
} else {
result, ok := os.LookupEnv(name)
if ok {
env = kobject.EnvVar{Name: name, Value: result}
} else {
continue
}
}
serviceConfig.Environment = append(serviceConfig.Environment, env)
}