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

Function createNetworks

cli/command/stack/deploy_composefile.go:172–200  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions)

Source from the content-addressed store, hash-verified

170}
171
172func 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
202func 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()

Callers 1

deployComposeFunction · 0.85

Calls 5

getStackNetworksFunction · 0.85
NetworkCreateMethod · 0.80
ClientMethod · 0.65
OutMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…