(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions)
| 170 | } |
| 171 | |
| 172 | func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions) error { |
| 173 | apiClient := dockerCLI.Client() |
| 174 | |
| 175 | existingNetworks, err := getStackNetworks(ctx, apiClient, namespace.Name()) |
| 176 | if err != nil { |
| 177 | return err |
| 178 | } |
| 179 | |
| 180 | existingNetworkMap := make(map[string]network.Summary) |
| 181 | for _, nw := range existingNetworks.Items { |
| 182 | existingNetworkMap[nw.Name] = nw |
| 183 | } |
| 184 | |
| 185 | for name, createOpts := range networks { |
| 186 | if _, exists := existingNetworkMap[name]; exists { |
| 187 | continue |
| 188 | } |
| 189 | |
| 190 | if createOpts.Driver == "" { |
| 191 | createOpts.Driver = defaultNetworkDriver |
| 192 | } |
| 193 | |
| 194 | _, _ = fmt.Fprintln(dockerCLI.Out(), "Creating network", name) |
| 195 | if _, err := apiClient.NetworkCreate(ctx, name, createOpts); err != nil { |
| 196 | return fmt.Errorf("failed to create network %s: %w", name, err) |
| 197 | } |
| 198 | } |
| 199 | return nil |
| 200 | } |
| 201 | |
| 202 | func deployServices(ctx context.Context, dockerCLI command.Cli, services map[string]swarm.ServiceSpec, namespace convert.Namespace, sendAuth bool, resolveImage string) ([]string, error) { |
| 203 | apiClient := dockerCLI.Client() |
no test coverage detected
searching dependent graphs…