| ... | ... |
@@ -226,6 +226,18 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, |
| 226 | 226 |
} |
| 227 | 227 |
} |
| 228 | 228 |
|
| 229 |
+ envs := []string{}
|
|
| 230 |
+ |
|
| 231 |
+ for _, env := range flEnv {
|
|
| 232 |
+ arr := strings.Split(env, "=") |
|
| 233 |
+ if len(arr) > 1 {
|
|
| 234 |
+ envs = append(envs, env) |
|
| 235 |
+ } else {
|
|
| 236 |
+ v := os.Getenv(env) |
|
| 237 |
+ envs = append(envs, env+"="+v) |
|
| 238 |
+ } |
|
| 239 |
+ } |
|
| 240 |
+ |
|
| 229 | 241 |
var binds []string |
| 230 | 242 |
|
| 231 | 243 |
// add any bind targets to the list of container volumes |
| ... | ... |
@@ -298,7 +310,7 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, |
| 298 | 298 |
AttachStdin: flAttach.Get("stdin"),
|
| 299 | 299 |
AttachStdout: flAttach.Get("stdout"),
|
| 300 | 300 |
AttachStderr: flAttach.Get("stderr"),
|
| 301 |
- Env: flEnv, |
|
| 301 |
+ Env: envs, |
|
| 302 | 302 |
Cmd: runCmd, |
| 303 | 303 |
Dns: flDns, |
| 304 | 304 |
Image: image, |
| ... | ... |
@@ -973,14 +973,14 @@ func TestTty(t *testing.T) {
|
| 973 | 973 |
} |
| 974 | 974 |
|
| 975 | 975 |
func TestEnv(t *testing.T) {
|
| 976 |
+ os.Setenv("TRUE", "false")
|
|
| 976 | 977 |
runtime := mkRuntime(t) |
| 977 | 978 |
defer nuke(runtime) |
| 978 |
- container, _, err := runtime.Create(&Config{
|
|
| 979 |
- Image: GetTestImage(runtime).ID, |
|
| 980 |
- Cmd: []string{"env"},
|
|
| 981 |
- }, |
|
| 982 |
- "", |
|
| 983 |
- ) |
|
| 979 |
+ config, _, _, err := ParseRun([]string{"-e=FALSE=true", "-e=TRUE", GetTestImage(runtime).ID, "env"}, nil)
|
|
| 980 |
+ if err != nil {
|
|
| 981 |
+ t.Fatal(err) |
|
| 982 |
+ } |
|
| 983 |
+ container, _, err := runtime.Create(config, "") |
|
| 984 | 984 |
if err != nil {
|
| 985 | 985 |
t.Fatal(err) |
| 986 | 986 |
} |
| ... | ... |
@@ -1010,6 +1010,8 @@ func TestEnv(t *testing.T) {
|
| 1010 | 1010 |
"HOME=/", |
| 1011 | 1011 |
"container=lxc", |
| 1012 | 1012 |
"HOSTNAME=" + container.ShortID(), |
| 1013 |
+ "FALSE=true", |
|
| 1014 |
+ "TRUE=false", |
|
| 1013 | 1015 |
} |
| 1014 | 1016 |
sort.Strings(goodEnv) |
| 1015 | 1017 |
if len(goodEnv) != len(actualEnv) {
|