(ctx context.Context, apiClient client.NetworkAPIClient, externalNetworks []string)
| 88 | } |
| 89 | |
| 90 | func 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 | |
| 110 | func createSecrets(ctx context.Context, dockerCLI command.Cli, secrets []swarm.SecretSpec) error { |
| 111 | apiClient := dockerCLI.Client() |
searching dependent graphs…