mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Any newly added data to an existing marshalled object must nil check
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
e5ee4ada8b
commit
2a392e5a98
1 changed files with 11 additions and 2 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/libnetwork/datastore"
|
"github.com/docker/libnetwork/datastore"
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/libnetwork/etchosts"
|
"github.com/docker/libnetwork/etchosts"
|
||||||
|
"github.com/docker/libnetwork/ipamapi"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/options"
|
"github.com/docker/libnetwork/options"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
|
@ -359,17 +360,25 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
|
||||||
}
|
}
|
||||||
n.name = netMap["name"].(string)
|
n.name = netMap["name"].(string)
|
||||||
n.id = netMap["id"].(string)
|
n.id = netMap["id"].(string)
|
||||||
n.ipamType = netMap["ipamType"].(string)
|
|
||||||
n.addrSpace = netMap["addrSpace"].(string)
|
|
||||||
n.networkType = netMap["networkType"].(string)
|
n.networkType = netMap["networkType"].(string)
|
||||||
n.endpointCnt = uint64(netMap["endpointCnt"].(float64))
|
n.endpointCnt = uint64(netMap["endpointCnt"].(float64))
|
||||||
n.enableIPv6 = netMap["enableIPv6"].(bool)
|
n.enableIPv6 = netMap["enableIPv6"].(bool)
|
||||||
|
|
||||||
if v, ok := netMap["generic"]; ok {
|
if v, ok := netMap["generic"]; ok {
|
||||||
n.generic = v.(map[string]interface{})
|
n.generic = v.(map[string]interface{})
|
||||||
}
|
}
|
||||||
if v, ok := netMap["persist"]; ok {
|
if v, ok := netMap["persist"]; ok {
|
||||||
n.persist = v.(bool)
|
n.persist = v.(bool)
|
||||||
}
|
}
|
||||||
|
if v, ok := netMap["ipamType"]; ok {
|
||||||
|
n.ipamType = v.(string)
|
||||||
|
} else {
|
||||||
|
n.ipamType = ipamapi.DefaultIPAM
|
||||||
|
}
|
||||||
|
|
||||||
|
if v, ok := netMap["addrSpace"]; ok {
|
||||||
|
n.addrSpace = v.(string)
|
||||||
|
}
|
||||||
if v, ok := netMap["ipamV4Config"]; ok {
|
if v, ok := netMap["ipamV4Config"]; ok {
|
||||||
if err := json.Unmarshal([]byte(v.(string)), &n.ipamV4Config); err != nil {
|
if err := json.Unmarshal([]byte(v.(string)), &n.ipamV4Config); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue