Merge pull request #604 from mavenugo/vin-fixes

Fixed a few issues identified during docker integration
This commit is contained in:
aboch 2015-10-08 15:35:54 -07:00
commit dce266d406
3 changed files with 11 additions and 6 deletions

View File

@ -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

View File

@ -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")
}
}

View File

@ -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