mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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 <abhi@docker.com>
This commit is contained in:
parent
2f8a3afcf3
commit
5bfefb2d36
1 changed files with 12 additions and 0 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/libnetwork"
|
||||
netconst "github.com/docker/libnetwork/datastore"
|
||||
"github.com/docker/libnetwork/networkdb"
|
||||
)
|
||||
|
||||
|
@ -135,6 +136,17 @@ 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
|
||||
// or if the get network was passed with a network name and scope as swarm
|
||||
// return the network. Skipped using isMatchingScope because it is true if the scope
|
||||
// is not set which would be case if the client API v1.30
|
||||
if strings.HasPrefix(nwk.ID, term) || (netconst.SwarmScope == scope) {
|
||||
return httputils.WriteJSON(w, http.StatusOK, nwk)
|
||||
}
|
||||
}
|
||||
|
||||
nr, _ := n.cluster.GetNetworks()
|
||||
for _, network := range nr {
|
||||
if network.ID == term && isMatchingScope(network.Scope, scope) {
|
||||
|
|
Loading…
Add table
Reference in a new issue