(ctx context.Context, containers []scalingo.Container, typeName string)
| 12 | ) |
| 13 | |
| 14 | func keepUniqueContainersWithType(ctx context.Context, containers []scalingo.Container, typeName string) (map[string]scalingo.Container, error) { |
| 15 | containersToKill := map[string]scalingo.Container{} |
| 16 | |
| 17 | hasMatched := false |
| 18 | prefix := typeName + "-" |
| 19 | for _, container := range containers { |
| 20 | if strings.HasPrefix(container.Label, prefix) { |
| 21 | containersToKill[container.Label] = container |
| 22 | hasMatched = true |
| 23 | } |
| 24 | } |
| 25 | if !hasMatched { |
| 26 | return containersToKill, errors.Newf(ctx, "'%v' did not match any container", typeName) |
| 27 | } |
| 28 | |
| 29 | return containersToKill, nil |
| 30 | } |
| 31 | |
| 32 | func keepUniqueContainersWithNames(ctx context.Context, containers []scalingo.Container, names []string) map[string]scalingo.Container { |
| 33 | containersToKill := map[string]scalingo.Container{} |
no outgoing calls
no test coverage detected