mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
runconfig: deprecate IsPreDefinedNetwork
Move the function internal to the daemon, where it's used. Deliberately not mentioning the new location, as this function should not be used externally. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -94,9 +93,9 @@ func filterNetworkByUse(nws []network.Inspect, danglingOnly bool) []network.Insp
|
||||
|
||||
filterFunc := func(nw network.Inspect) bool {
|
||||
if danglingOnly {
|
||||
return !runconfig.IsPreDefinedNetwork(nw.Name) && len(nw.Containers) == 0 && len(nw.Services) == 0
|
||||
return !IsPredefined(nw.Name) && len(nw.Containers) == 0 && len(nw.Services) == 0
|
||||
}
|
||||
return runconfig.IsPreDefinedNetwork(nw.Name) || len(nw.Containers) > 0 || len(nw.Services) > 0
|
||||
return IsPredefined(nw.Name) || len(nw.Containers) > 0 || len(nw.Services) > 0
|
||||
}
|
||||
|
||||
for _, nw := range nws {
|
||||
@@ -113,13 +112,13 @@ func filterNetworkByType(nws []network.Inspect, netType string) ([]network.Inspe
|
||||
switch netType {
|
||||
case "builtin":
|
||||
for _, nw := range nws {
|
||||
if runconfig.IsPreDefinedNetwork(nw.Name) {
|
||||
if IsPredefined(nw.Name) {
|
||||
retNws = append(retNws, nw)
|
||||
}
|
||||
}
|
||||
case "custom":
|
||||
for _, nw := range nws {
|
||||
if !runconfig.IsPreDefinedNetwork(nw.Name) {
|
||||
if !IsPredefined(nw.Name) {
|
||||
retNws = append(retNws, nw)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,3 +5,9 @@ package network
|
||||
// ([network.NetworkBridge]), and "nat" ([network.NetworkNat]) for Windows
|
||||
// containers.
|
||||
const DefaultNetwork = defaultNetwork
|
||||
|
||||
// IsPredefined indicates if a network is predefined by the daemon.
|
||||
func IsPredefined(network string) bool {
|
||||
// TODO(thaJeztah): check if we can align the check for both platforms
|
||||
return isPreDefined(network)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
package network
|
||||
|
||||
import "github.com/docker/docker/api/types/network"
|
||||
import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
)
|
||||
|
||||
const defaultNetwork = network.NetworkBridge
|
||||
|
||||
func isPreDefined(network string) bool {
|
||||
n := container.NetworkMode(network)
|
||||
return n.IsBridge() || n.IsHost() || n.IsNone() || n.IsDefault()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package network
|
||||
|
||||
import "github.com/docker/docker/api/types/network"
|
||||
import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
)
|
||||
|
||||
const defaultNetwork = network.NetworkNat
|
||||
|
||||
func isPreDefined(network string) bool {
|
||||
return !container.NetworkMode(network).IsUserDefined()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user