mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #703 from sanimej/bfix
Fix Endpoint Unmarshal to retrieve the fields correctly
This commit is contained in:
commit
0c9eeec760
1 changed files with 45 additions and 0 deletions
|
@ -106,6 +106,51 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
|
||||||
if v, ok := epMap["generic"]; ok {
|
if v, ok := epMap["generic"]; ok {
|
||||||
ep.generic = v.(map[string]interface{})
|
ep.generic = v.(map[string]interface{})
|
||||||
|
|
||||||
|
if opt, ok := ep.generic[netlabel.PortMap]; ok {
|
||||||
|
pblist := []types.PortBinding{}
|
||||||
|
|
||||||
|
for i := 0; i < len(opt.([]interface{})); i++ {
|
||||||
|
pb := types.PortBinding{}
|
||||||
|
tmp := opt.([]interface{})[i].(map[string]interface{})
|
||||||
|
|
||||||
|
bytes, err := json.Marshal(tmp)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(bytes, &pb)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
pblist = append(pblist, pb)
|
||||||
|
}
|
||||||
|
ep.generic[netlabel.PortMap] = pblist
|
||||||
|
}
|
||||||
|
|
||||||
|
if opt, ok := ep.generic[netlabel.ExposedPorts]; ok {
|
||||||
|
tplist := []types.TransportPort{}
|
||||||
|
|
||||||
|
for i := 0; i < len(opt.([]interface{})); i++ {
|
||||||
|
tp := types.TransportPort{}
|
||||||
|
tmp := opt.([]interface{})[i].(map[string]interface{})
|
||||||
|
|
||||||
|
bytes, err := json.Marshal(tmp)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(bytes, &tp)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
tplist = append(tplist, tp)
|
||||||
|
}
|
||||||
|
ep.generic[netlabel.ExposedPorts] = tplist
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := epMap["anonymous"]; ok {
|
if v, ok := epMap["anonymous"]; ok {
|
||||||
|
|
Loading…
Add table
Reference in a new issue