1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Address code review feedback

Also make sure we copy the joining containers hosts and resolv.conf with
the hostname if we are joining it's network stack.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-05-02 16:59:28 -07:00
parent c1c6b3ccd9
commit 0b187b909b
3 changed files with 56 additions and 18 deletions

View file

@ -1,11 +1,24 @@
package runconfig
import (
"strings"
"github.com/dotcloud/docker/engine"
"github.com/dotcloud/docker/nat"
"github.com/dotcloud/docker/utils"
)
type NetworkMode string
func (n NetworkMode) IsHost() bool {
return n == "host"
}
func (n NetworkMode) IsContainer() bool {
parts := strings.SplitN(string(n), ":", 2)
return len(parts) > 1 && parts[0] == "container"
}
type HostConfig struct {
Binds []string
ContainerIDFile string
@ -17,7 +30,7 @@ type HostConfig struct {
Dns []string
DnsSearch []string
VolumesFrom []string
NetworkMode string
NetworkMode NetworkMode
}
func ContainerHostConfigFromJob(job *engine.Job) *HostConfig {
@ -25,7 +38,7 @@ func ContainerHostConfigFromJob(job *engine.Job) *HostConfig {
ContainerIDFile: job.Getenv("ContainerIDFile"),
Privileged: job.GetenvBool("Privileged"),
PublishAllPorts: job.GetenvBool("PublishAllPorts"),
NetworkMode: job.Getenv("NetworkMode"),
NetworkMode: NetworkMode(job.Getenv("NetworkMode")),
}
job.GetenvJson("LxcConf", &hostConfig.LxcConf)
job.GetenvJson("PortBindings", &hostConfig.PortBindings)