(ctx context.Context, projectName string, options api.KillOptions)
| 33 | } |
| 34 | |
| 35 | func (s *composeService) kill(ctx context.Context, projectName string, options api.KillOptions) error { |
| 36 | services := options.Services |
| 37 | |
| 38 | var containers Containers |
| 39 | containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, services...) |
| 40 | if err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | project := options.Project |
| 45 | if project == nil { |
| 46 | project, err = s.getProjectWithResources(ctx, containers, projectName) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if !options.RemoveOrphans { |
| 53 | containers = containers.filter(isService(project.ServiceNames()...)) |
| 54 | } |
| 55 | if len(containers) == 0 { |
| 56 | return api.ErrNoResources |
| 57 | } |
| 58 | |
| 59 | return forEachContainerConcurrent(ctx, containers, func(ctx context.Context, ctr container.Summary) error { |
| 60 | eventName := getContainerProgressName(ctr) |
| 61 | s.events.On(newEvent(eventName, api.Working, api.StatusKilling)) |
| 62 | _, err := s.apiClient().ContainerKill(ctx, ctr.ID, client.ContainerKillOptions{ |
| 63 | Signal: options.Signal, |
| 64 | }) |
| 65 | if err != nil { |
| 66 | s.events.On(errorEvent(eventName, "Error while Killing")) |
| 67 | return err |
| 68 | } |
| 69 | s.events.On(newEvent(eventName, api.Done, api.StatusKilled)) |
| 70 | return nil |
| 71 | }) |
| 72 | } |
no test coverage detected