(ctx context.Context, service, id, name string, listener api.ContainerEventListener)
| 70 | } |
| 71 | |
| 72 | func (s *composeService) doAttachContainer(ctx context.Context, service, id, name string, listener api.ContainerEventListener) error { |
| 73 | inspect, err := s.apiClient().ContainerInspect(ctx, id, client.ContainerInspectOptions{}) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | wOut := utils.GetWriter(func(line string) { |
| 79 | listener(api.ContainerEvent{ |
| 80 | Type: api.ContainerEventLog, |
| 81 | Source: name, |
| 82 | ID: id, |
| 83 | Service: service, |
| 84 | Line: line, |
| 85 | }) |
| 86 | }) |
| 87 | wErr := utils.GetWriter(func(line string) { |
| 88 | listener(api.ContainerEvent{ |
| 89 | Type: api.ContainerEventErr, |
| 90 | Source: name, |
| 91 | ID: id, |
| 92 | Service: service, |
| 93 | Line: line, |
| 94 | }) |
| 95 | }) |
| 96 | |
| 97 | err = s.attachContainerStreams(ctx, id, inspect.Container.Config.Tty, wOut, wErr) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | return nil |
| 103 | } |
| 104 | |
| 105 | func (s *composeService) attachContainerStreams(ctx context.Context, container string, tty bool, stdout, stderr io.WriteCloser) error { |
| 106 | streamOut, err := s.getContainerStreams(ctx, container) |
no test coverage detected