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

Method getContainersByService

pkg/compose/containers.go:61–72  ·  view source on GitHub ↗

getContainersByService returns all non-oneoff containers for the project, grouped by service name.

(ctx context.Context, projectName string)

Source from the content-addressed store, hash-verified

59
60// getContainersByService returns all non-oneoff containers for the project, grouped by service name.
61func (s *composeService) getContainersByService(ctx context.Context, projectName string) (map[string]Containers, error) {
62 all, err := s.getContainers(ctx, projectName, oneOffExclude, true)
63 if err != nil {
64 return nil, err
65 }
66 result := map[string]Containers{}
67 for _, c := range all.filter(isNotOneOff) {
68 svc := c.Labels[api.ServiceLabel]
69 result[svc] = append(result[svc], c)
70 }
71 return result, nil
72}
73
74func getDefaultFilters(projectName string, oneOff oneOff, selectedServices ...string) client.Filters {
75 f := projectFilter(projectName)

Callers 1

Calls 2

getContainersMethod · 0.95
filterMethod · 0.80

Tested by

no test coverage detected