MCPcopy Index your code
hub / github.com/docker/cli / validateExternalNetworks

Function validateExternalNetworks

cli/command/stack/deploy_composefile.go:90–108  ·  view source on GitHub ↗
(ctx context.Context, apiClient client.NetworkAPIClient, externalNetworks []string)

Source from the content-addressed store, hash-verified

88}
89
90func validateExternalNetworks(ctx context.Context, apiClient client.NetworkAPIClient, externalNetworks []string) error {
91 for _, networkName := range externalNetworks {
92 if !container.NetworkMode(networkName).IsUserDefined() {
93 // Networks that are not user defined always exist on all nodes as
94 // local-scoped networks, so there's no need to inspect them.
95 continue
96 }
97 res, err := apiClient.NetworkInspect(ctx, networkName, client.NetworkInspectOptions{})
98 switch {
99 case errdefs.IsNotFound(err):
100 return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName)
101 case err != nil:
102 return err
103 case res.Network.Scope != "swarm":
104 return fmt.Errorf("network %q is declared as external, but it is not in the right scope: %q instead of \"swarm\"", networkName, res.Network.Scope)
105 }
106 }
107 return nil
108}
109
110func createSecrets(ctx context.Context, dockerCLI command.Cli, secrets []swarm.SecretSpec) error {
111 apiClient := dockerCLI.Client()

Callers 2

deployComposeFunction · 0.85

Calls 2

NetworkModeMethod · 0.80
NetworkInspectMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…