connectPreStartExtraNetworks mirrors the createMobyContainer fallback path for older API versions: ContainerCreate only accepts one EndpointsConfig, so extra networks have to be attached via NetworkConnect after creation.
(ctx context.Context, project *types.Project, service types.ServiceConfig, containerID string, primary container.NetworkMode)
| 190 | // older API versions: ContainerCreate only accepts one EndpointsConfig, so extra |
| 191 | // networks have to be attached via NetworkConnect after creation. |
| 192 | func (s *composeService) connectPreStartExtraNetworks(ctx context.Context, project *types.Project, service types.ServiceConfig, containerID string, primary container.NetworkMode) error { |
| 193 | for _, networkKey := range service.NetworksByPriority() { |
| 194 | mobyNetworkName := project.Networks[networkKey].Name |
| 195 | if string(primary) == mobyNetworkName { |
| 196 | continue |
| 197 | } |
| 198 | eps, err := createEndpointSettings(project, service, 0, networkKey, nil, true) |
| 199 | if err != nil { |
| 200 | return err |
| 201 | } |
| 202 | if _, err := s.apiClient().NetworkConnect(ctx, mobyNetworkName, client.NetworkConnectOptions{ |
| 203 | Container: containerID, |
| 204 | EndpointConfig: eps, |
| 205 | }); err != nil { |
| 206 | return err |
| 207 | } |
| 208 | } |
| 209 | return nil |
| 210 | } |
| 211 | |
| 212 | func waitPreStart(ctx context.Context, serviceName string, index int, waitRes client.ContainerWaitResult) error { |
| 213 | // ContainerWait can deliver on Result and Error at the same instant. Two |
no test coverage detected