mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move ReplaceOrAppendEnvValues to container package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
04f7a03359
commit
7164b66cfc
5 changed files with 11 additions and 14 deletions
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/pkg/symlink"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/utils"
|
||||
"github.com/docker/docker/volume"
|
||||
"github.com/opencontainers/runc/libcontainer/label"
|
||||
"golang.org/x/sys/unix"
|
||||
|
@ -69,7 +68,7 @@ func (container *Container) CreateDaemonEnvironment(tty bool, linkedEnv []string
|
|||
// because the env on the container can override certain default values
|
||||
// we need to replace the 'env' keys where they match and append anything
|
||||
// else.
|
||||
env = utils.ReplaceOrAppendEnvValues(env, container.Config.Env)
|
||||
env = ReplaceOrAppendEnvValues(env, container.Config.Env)
|
||||
return env
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
// Container holds fields specific to the Windows implementation. See
|
||||
|
@ -30,7 +29,7 @@ func (container *Container) CreateDaemonEnvironment(_ bool, linkedEnv []string)
|
|||
// because the env on the container can override certain default values
|
||||
// we need to replace the 'env' keys where they match and append anything
|
||||
// else.
|
||||
return utils.ReplaceOrAppendEnvValues(linkedEnv, container.Config.Env)
|
||||
return ReplaceOrAppendEnvValues(linkedEnv, container.Config.Env)
|
||||
}
|
||||
|
||||
// UnmountIpcMounts unmounts Ipc related mounts.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package utils
|
||||
package container
|
||||
|
||||
import (
|
||||
"strings"
|
|
@ -1,4 +1,4 @@
|
|||
package utils
|
||||
package container
|
||||
|
||||
import "testing"
|
||||
|
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/docker/docker/pkg/pools"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/docker/docker/pkg/term"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
// Seconds to wait after sending TERM before trying KILL
|
||||
|
@ -94,7 +93,7 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) {
|
|||
|
||||
// ContainerExecCreate sets up an exec in a running container.
|
||||
func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (string, error) {
|
||||
container, err := d.getActiveContainer(name)
|
||||
cntr, err := d.getActiveContainer(name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
|
|||
execConfig.OpenStdin = config.AttachStdin
|
||||
execConfig.OpenStdout = config.AttachStdout
|
||||
execConfig.OpenStderr = config.AttachStderr
|
||||
execConfig.ContainerID = container.ID
|
||||
execConfig.ContainerID = cntr.ID
|
||||
execConfig.DetachKeys = keys
|
||||
execConfig.Entrypoint = entrypoint
|
||||
execConfig.Args = args
|
||||
|
@ -123,18 +122,18 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
|
|||
execConfig.Privileged = config.Privileged
|
||||
execConfig.User = config.User
|
||||
|
||||
linkedEnv, err := d.setupLinkedContainers(container)
|
||||
linkedEnv, err := d.setupLinkedContainers(cntr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
execConfig.Env = utils.ReplaceOrAppendEnvValues(container.CreateDaemonEnvironment(config.Tty, linkedEnv), config.Env)
|
||||
execConfig.Env = container.ReplaceOrAppendEnvValues(cntr.CreateDaemonEnvironment(config.Tty, linkedEnv), config.Env)
|
||||
if len(execConfig.User) == 0 {
|
||||
execConfig.User = container.Config.User
|
||||
execConfig.User = cntr.Config.User
|
||||
}
|
||||
|
||||
d.registerExecCommand(container, execConfig)
|
||||
d.registerExecCommand(cntr, execConfig)
|
||||
|
||||
d.LogContainerEvent(container, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "))
|
||||
d.LogContainerEvent(cntr, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "))
|
||||
|
||||
return execConfig.ID, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue