(ctx context.Context, project *types.Project, listener api.ContainerEventListener, selectedServices []string)
| 34 | ) |
| 35 | |
| 36 | func (s *composeService) attach(ctx context.Context, project *types.Project, listener api.ContainerEventListener, selectedServices []string) (Containers, error) { |
| 37 | containers, err := s.getContainers(ctx, project.Name, oneOffExclude, true, selectedServices...) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | if len(containers) == 0 { |
| 42 | return containers, nil |
| 43 | } |
| 44 | |
| 45 | containers.sorted() // This enforces predictable colors assignment |
| 46 | |
| 47 | var names []string |
| 48 | for _, c := range containers { |
| 49 | names = append(names, getContainerNameWithoutProject(c)) |
| 50 | } |
| 51 | |
| 52 | _, err = fmt.Fprintf(s.stdout(), "Attaching to %s\n", strings.Join(names, ", ")) |
| 53 | if err != nil { |
| 54 | logrus.Debugf("failed to write attach message: %v", err) |
| 55 | } |
| 56 | |
| 57 | for _, ctr := range containers { |
| 58 | err := s.attachContainer(ctx, ctr, listener) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | } |
| 63 | return containers, nil |
| 64 | } |
| 65 | |
| 66 | func (s *composeService) attachContainer(ctx context.Context, container containerType.Summary, listener api.ContainerEventListener) error { |
| 67 | service := container.Labels[api.ServiceLabel] |
no test coverage detected