diff --git a/libnetwork/config/config.go b/libnetwork/config/config.go index 0121c06630..474d04a47a 100644 --- a/libnetwork/config/config.go +++ b/libnetwork/config/config.go @@ -152,7 +152,7 @@ func (c *Config) ProcessOptions(options ...Option) { // IsValidName validates configuration objects supported by libnetwork func IsValidName(name string) bool { - if strings.TrimSpace(name) == "" || strings.Contains(name, ".") { + if strings.TrimSpace(name) == "" { return false } return true diff --git a/libnetwork/config/config_test.go b/libnetwork/config/config_test.go index 876078687f..91fb43551e 100644 --- a/libnetwork/config/config_test.go +++ b/libnetwork/config/config_test.go @@ -52,7 +52,4 @@ func TestValidName(t *testing.T) { if IsValidName(" ") { t.Fatal("Name validation succeeds for a case when it is expected to fail") } - if IsValidName("name.with.dots") { - t.Fatal("Name validation succeeds for a case when it is expected to fail") - } } diff --git a/libnetwork/network.go b/libnetwork/network.go index 486f40380e..457d5748a5 100644 --- a/libnetwork/network.go +++ b/libnetwork/network.go @@ -376,17 +376,25 @@ func (n *network) UnmarshalJSON(b []byte) (err error) { } n.name = netMap["name"].(string) n.id = netMap["id"].(string) - n.ipamType = netMap["ipamType"].(string) - n.addrSpace = netMap["addrSpace"].(string) n.networkType = netMap["networkType"].(string) n.endpointCnt = uint64(netMap["endpointCnt"].(float64)) n.enableIPv6 = netMap["enableIPv6"].(bool) + if v, ok := netMap["generic"]; ok { n.generic = v.(map[string]interface{}) } if v, ok := netMap["persist"]; ok { 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 err := json.Unmarshal([]byte(v.(string)), &n.ipamV4Config); err != nil { return err