From d15bb75ce7220bad7445c8221d7bd8f87790bdf3 Mon Sep 17 00:00:00 2001 From: Abhinandan Prativadi Date: Fri, 28 Jul 2017 13:50:10 -0700 Subject: [PATCH] Changing the get network request to return swarm scope predefined networks Starting 17.06 swarm service create supports service creates with predefined networks like host and bridge. Due to the nature of the feature, swarm manager has a swarm scope predefined networks in addition to local scoped predefined networks on all nodes. However network inspects for swarm scoped predefined networks was not possible. The fix adds support for network inspect for swarm scoped predefined networks. Signed-off-by: Abhinandan Prativadi --- .../engine/api/server/router/network/network_routes.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/engine/api/server/router/network/network_routes.go b/components/engine/api/server/router/network/network_routes.go index bff3561523f..f284bbef8fb 100644 --- a/components/engine/api/server/router/network/network_routes.go +++ b/components/engine/api/server/router/network/network_routes.go @@ -126,7 +126,13 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r listByPartialID[network.ID()] = *n.buildDetailedNetworkResources(network, verbose) } } - + nwk, err := n.cluster.GetNetwork(term) + // If the get network inspect requests with network ID / partial network ID + if err == nil { + if nwk.ID == term || strings.HasPrefix(nwk.ID, term) { + return httputils.WriteJSON(w, http.StatusOK, nwk) + } + } nr, _ := n.cluster.GetNetworks() for _, network := range nr { if network.ID == term {