Bladeren bron

Merge pull request #24634 from thaJeztah/make-network-name-required

API return network-list if no network-name or id is provided
Vincent Demeester 8 jaren geleden
bovenliggende
commit
b826bebda0
3 gewijzigde bestanden met toevoegingen van 6 en 1 verwijderingen
  1. 2 1
      api/server/router/network/network.go
  2. 1 0
      daemon/network.go
  3. 3 0
      docs/reference/api/docker_remote_api.md

+ 2 - 1
api/server/router/network/network.go

@@ -31,7 +31,8 @@ func (r *networkRouter) initRoutes() {
 	r.routes = []router.Route{
 		// GET
 		router.NewGetRoute("/networks", r.getNetworksList),
-		router.NewGetRoute("/networks/{id:.*}", r.getNetwork),
+		router.NewGetRoute("/networks/", r.getNetworksList),
+		router.NewGetRoute("/networks/{id:.+}", r.getNetwork),
 		// POST
 		router.NewPostRoute("/networks/create", r.postNetworkCreate),
 		router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),

+ 1 - 0
daemon/network.go

@@ -59,6 +59,7 @@ func (daemon *Daemon) GetNetworkByID(partialID string) (libnetwork.Network, erro
 }
 
 // GetNetworkByName function returns a network for a given network name.
+// If no network name is given, the default network is returned.
 func (daemon *Daemon) GetNetworkByName(name string) (libnetwork.Network, error) {
 	c := daemon.netController
 	if c == nil {

+ 3 - 0
docs/reference/api/docker_remote_api.md

@@ -125,6 +125,9 @@ This section lists each version from latest to oldest.  Each listing includes a
 * `POST /containers/create` now takes a `Mounts` field in `HostConfig` which replaces `Binds` and `Volumes`. *note*: `Binds` and `Volumes` are still available but are exclusive with `Mounts`
 * `POST /build` now performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. Note that this change is _unversioned_ and applied to all API versions.
 * `POST /build` accepts `cachefrom` parameter to specify images used for build cache.
+* `GET /networks/` endpoint now correctly returns a list of *all* networks,
+  instead of the default network if a trailing slash is provided, but no `name`
+  or `id`.
 
 ### v1.24 API changes