forEachContainerConcurrent runs fn for every container concurrently and waits for all goroutines.
(ctx context.Context, containers Containers, fn func(context.Context, container.Summary) error)
| 179 | |
| 180 | // forEachContainerConcurrent runs fn for every container concurrently and waits for all goroutines. |
| 181 | func forEachContainerConcurrent(ctx context.Context, containers Containers, fn func(context.Context, container.Summary) error) error { |
| 182 | eg, ctx := errgroup.WithContext(ctx) |
| 183 | for _, ctr := range containers { |
| 184 | eg.Go(func() error { |
| 185 | return fn(ctx, ctr) |
| 186 | }) |
| 187 | } |
| 188 | return eg.Wait() |
| 189 | } |
| 190 | |
| 191 | // sorted sorts containers in place by canonical name and returns the (same) slice. |
| 192 | func (containers Containers) sorted() Containers { |