MCPcopy
hub / github.com/docker/compose / removeResource

Method removeResource

pkg/compose/down.go:280–296  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
280func (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
298func (s *composeService) stopContainer(ctx context.Context, service *types.ServiceConfig, ctr containerType.Summary, timeout *time.Duration, listener api.ContainerEventListener) error {
299 eventName := getContainerProgressName(ctr)

Callers 2

removeImageMethod · 0.95
removeVolumeMethod · 0.95

Calls 2

newEventFunction · 0.85
OnMethod · 0.65

Tested by

no test coverage detected