removeResource emits a "Removing" progress event, calls op, then emits the appropriate completion event based on the error: nil→Removed, conflict→still-in-use warning, not-found→gone warning.
(eventID string, op func() error)
| 278 | // removeResource emits a "Removing" progress event, calls op, then emits the appropriate |
| 279 | // completion event based on the error: nil→Removed, conflict→still-in-use warning, not-found→gone warning. |
| 280 | func (s *composeService) removeResource(eventID string, op func() error) error { |
| 281 | s.events.On(newEvent(eventID, api.Working, "Removing")) |
| 282 | err := op() |
| 283 | if err == nil { |
| 284 | s.events.On(newEvent(eventID, api.Done, "Removed")) |
| 285 | return nil |
| 286 | } |
| 287 | if errdefs.IsConflict(err) { |
| 288 | s.events.On(newEvent(eventID, api.Warning, "Resource is still in use")) |
| 289 | return nil |
| 290 | } |
| 291 | if errdefs.IsNotFound(err) { |
| 292 | s.events.On(newEvent(eventID, api.Done, "Warning: No resource found to remove")) |
| 293 | return nil |
| 294 | } |
| 295 | return err |
| 296 | } |
| 297 | |
| 298 | func (s *composeService) stopContainer(ctx context.Context, service *types.ServiceConfig, ctr containerType.Summary, timeout *time.Duration, listener api.ContainerEventListener) error { |
| 299 | eventName := getContainerProgressName(ctr) |
no test coverage detected