Merge pull request #150 from abhinandanpb/predefinednet

[17.06] Changing get network request to return predefined network in swarm
This commit is contained in:
Andrew Hsu
2017-08-01 11:09:10 -07:00
committed by GitHub

View File

@ -127,6 +127,15 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
}
}
nwk, err := n.cluster.GetNetwork(term)
if err == nil {
// If the get network is passed with a specific network ID / partial network ID
// return the network.
if strings.HasPrefix(nwk.ID, term) {
return httputils.WriteJSON(w, http.StatusOK, nwk)
}
}
nr, _ := n.cluster.GetNetworks()
for _, network := range nr {
if network.ID == term {