Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: pouch exec with envs will not replace old envs #2275

Merged
merged 1 commit into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daemon/mgr/container_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config
return "", fmt.Errorf("container %s is not running", c.ID)
}

envs, err := mergeEnvSlice(c.Config.Env, config.Env)
envs, err := mergeEnvSlice(config.Env, c.Config.Env)

if err != nil {
return "", err
Expand Down
21 changes: 21 additions & 0 deletions test/cli_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ func (suite *PouchExecSuite) TestExecWithEnvs(c *check.C) {
}
}

// TestExecWithReplaceEnvs is to verify New Envs will replace old Envs.
func (suite *PouchExecSuite) TestExecWithReplaceEnvs(c *check.C) {
name := "exec-normal4"
res := command.PouchRun("run", "-d", "-e", "Test=Old", "--name", name, busyboxImage, "sleep", "100000")
defer DelContainerForceMultyTime(c, name)

res.Assert(c, icmd.Success)

res = command.PouchRun("exec", name, "env")

if out := res.Combined(); !strings.Contains(out, "Test=Old") {
c.Fatalf("unexpected output %s expected %s\n", out, name)
}

res = command.PouchRun("exec", "-e \"Test=New\"", name, "env")

if out := res.Combined(); !strings.Contains(out, "Test=New") {
c.Fatalf("unexpected output %s expected %s\n", out, name)
}
}

// TestExecEcho tests exec prints the output.
func (suite *PouchExecSuite) TestExecEcho(c *check.C) {
name := "TestExecEcho"
Expand Down