From ad5286acd91f26140978c3eb787741477371419c Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Mon, 23 Jun 2014 20:40:37 +0000 Subject: [PATCH] Addressed more comments. Docker-DCO-1.1-Signed-off-by: Vishnu Kannan (github: vishh) --- container.go | 3 +-- namespaces/exec.go | 2 +- namespaces/init.go | 2 +- network/types.go | 6 +++--- utils.go | 11 ++--------- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/container.go b/container.go index 05d0a84b..88c3e23b 100644 --- a/container.go +++ b/container.go @@ -6,10 +6,9 @@ import ( "github.com/docker/libcontainer/mount" ) -// Reusing internal Mount struct since we don't expect the API and the internal representation to differ much in the future. type Mount mount.Mount -type Mounts []Mount +type Mounts mount.Mounts type Network struct { // Type sets the networks type, commonly veth and loopback diff --git a/namespaces/exec.go b/namespaces/exec.go index 0b5d4f5e..2cc859c6 100644 --- a/namespaces/exec.go +++ b/namespaces/exec.go @@ -157,7 +157,7 @@ func InitializeNetworking(container *libcontainer.Container, nspid int, pipe *Sy if err != nil { return err } - if err := strategy.Create(libcontainer.GetInternalNetworkSpec(config), nspid, context); err != nil { + if err := strategy.Create(libcontainer.GetInternalNetworkConfig(config), nspid, context); err != nil { return err } } diff --git a/namespaces/init.go b/namespaces/init.go index 8ea4ef69..7385067b 100644 --- a/namespaces/init.go +++ b/namespaces/init.go @@ -166,7 +166,7 @@ func setupNetwork(container *libcontainer.Container, context map[string]string) return err } - err1 := strategy.Initialize(libcontainer.GetInternalNetworkSpec(config), context) + err1 := strategy.Initialize(libcontainer.GetInternalNetworkConfig(config), context) if err1 != nil { return err1 } diff --git a/network/types.go b/network/types.go index 6a7fe3ee..e4ebbb2b 100644 --- a/network/types.go +++ b/network/types.go @@ -9,13 +9,13 @@ type Network struct { Type string `json:"type,omitempty"` // Path to network namespace - NsPath string + NsPath string `json:"ns_path,omitempty"` // The bridge to use. - Bridge string + Bridge string `json:"bridge,omitempty"` // Prefix for the veth interfaces. - VethPrefix string + VethPrefix string `json:"type,omitempty"` // Address contains the IP and mask to set on the network interface Address string `json:"address,omitempty"` diff --git a/utils.go b/utils.go index a4e2e884..3ba66a91 100644 --- a/utils.go +++ b/utils.go @@ -12,19 +12,12 @@ func GetInternalMountConfig(container *Container) *mount.MountConfig { ReadonlyFs: container.ReadonlyFs, DeviceNodes: container.DeviceNodes, MountLabel: container.Context["mount_label"], - } - for _, mountFromSpec := range container.Mounts { - out.Mounts = append(out.Mounts, mount.Mount{ - Type: mountFromSpec.Type, - Source: mountFromSpec.Source, - Destination: mountFromSpec.Destination, - Writable: mountFromSpec.Writable, - Private: mountFromSpec.Private}) + Mounts: (mount.Mounts)(container.Mounts), } return out } -func GetInternalNetworkSpec(net *Network) *network.Network { +func GetInternalNetworkConfig(net *Network) *network.Network { return &network.Network{ Type: net.Type, NsPath: net.Context["nspath"],