MCPcopy Create free account
hub / github.com/Scalingo/cli / keepUniqueContainersWithType

Function keepUniqueContainersWithType

apps/sendsignal.go:14–30  ·  view source on GitHub ↗
(ctx context.Context, containers []scalingo.Container, typeName string)

Source from the content-addressed store, hash-verified

12)
13
14func 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
32func keepUniqueContainersWithNames(ctx context.Context, containers []scalingo.Container, names []string) map[string]scalingo.Container {
33 containersToKill := map[string]scalingo.Container{}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected