Skip to content

Commit

Permalink
Support attachable in network.
Browse files Browse the repository at this point in the history
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
  • Loading branch information
dongluochen committed Nov 9, 2016
1 parent 154b532 commit e927d37
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type NetworkInfo interface {
Scope() string
IPv6Enabled() bool
Internal() bool
Attachable() bool
Labels() map[string]string
Dynamic() bool
Created() time.Time
Expand Down Expand Up @@ -196,6 +197,7 @@ type network struct {
resolverOnce sync.Once
resolver []Resolver
internal bool
attachable bool
inDelete bool
ingress bool
driverTables []string
Expand Down Expand Up @@ -348,6 +350,7 @@ func (n *network) CopyTo(o datastore.KVObject) error {
dstN.dbExists = n.dbExists
dstN.drvOnce = n.drvOnce
dstN.internal = n.internal
dstN.attachable = n.attachable
dstN.inDelete = n.inDelete
dstN.ingress = n.ingress

Expand Down Expand Up @@ -456,6 +459,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
netMap["ipamV6Info"] = string(iis)
}
netMap["internal"] = n.internal
netMap["attachable"] = n.attachable
netMap["inDelete"] = n.inDelete
netMap["ingress"] = n.ingress
return json.Marshal(netMap)
Expand Down Expand Up @@ -550,6 +554,9 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
if v, ok := netMap["internal"]; ok {
n.internal = v.(bool)
}
if v, ok := netMap["attachable"]; ok {
n.attachable = v.(bool)
}
if s, ok := netMap["scope"]; ok {
n.scope = s.(string)
}
Expand Down Expand Up @@ -628,6 +635,13 @@ func NetworkOptionInternalNetwork() NetworkOption {
}
}

// NetworkOptionAttachable returns an option setter to set attachable for a network
func NetworkOptionAttachable(attachable bool) NetworkOption {
return func(n *network) {
n.attachable = attachable
}
}

// NetworkOptionIpam function returns an option setter for the ipam configuration for this network
func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ipV6 []*IpamConf, opts map[string]string) NetworkOption {
return func(n *network) {
Expand Down Expand Up @@ -1555,6 +1569,13 @@ func (n *network) Internal() bool {
return n.internal
}

func (n *network) Attachable() bool {
n.Lock()
defer n.Unlock()

return n.attachable
}

func (n *network) Dynamic() bool {
n.Lock()
defer n.Unlock()
Expand Down

0 comments on commit e927d37

Please sign in to comment.