mirror of
https://github.com/cuigh/swirl
synced 2025-01-01 00:32:09 +00:00
Fix external network validation
This commit is contained in:
parent
da9b47de15
commit
49eaee7cec
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/cuigh/swirl/biz/docker/compose"
|
"github.com/cuigh/swirl/biz/docker/compose"
|
||||||
"github.com/cuigh/swirl/model"
|
"github.com/cuigh/swirl/model"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -218,6 +219,11 @@ func StackDeploy(name, content string, authes map[string]string) error {
|
|||||||
|
|
||||||
func validateExternalNetworks(ctx context.Context, cli *client.Client, externalNetworks []string) error {
|
func validateExternalNetworks(ctx context.Context, cli *client.Client, externalNetworks []string) error {
|
||||||
for _, networkName := range externalNetworks {
|
for _, networkName := range externalNetworks {
|
||||||
|
if !container.NetworkMode(networkName).IsUserDefined() {
|
||||||
|
// Networks that are not user defined always exist on all nodes as
|
||||||
|
// local-scoped networks, so there's no need to inspect them.
|
||||||
|
continue
|
||||||
|
}
|
||||||
network, err := cli.NetworkInspect(ctx, networkName, types.NetworkInspectOptions{})
|
network, err := cli.NetworkInspect(ctx, networkName, types.NetworkInspectOptions{})
|
||||||
switch {
|
switch {
|
||||||
case client.IsErrNotFound(err):
|
case client.IsErrNotFound(err):
|
||||||
|
Loading…
Reference in New Issue
Block a user