exclude one-off container running convergence

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2025-01-08 10:19:46 +01:00 committed by Guillaume Lours
parent 2ebb475433
commit b6db1380ec
2 changed files with 12 additions and 3 deletions

View File

@ -114,6 +114,15 @@ func (s *composeService) getSpecifiedContainer(ctx context.Context, projectName
// containerPredicate define a predicate we want container to satisfy for filtering operations
type containerPredicate func(c moby.Container) bool
func matches(c moby.Container, predicates ...containerPredicate) bool {
for _, predicate := range predicates {
if !predicate(c) {
return false
}
}
return true
}
func isService(services ...string) containerPredicate {
return func(c moby.Container) bool {
service := c.Labels[api.ServiceLabel]
@ -148,10 +157,10 @@ func isNotOneOff(c moby.Container) bool {
}
// filter return Containers with elements to match predicate
func (containers Containers) filter(predicate containerPredicate) Containers {
func (containers Containers) filter(predicates ...containerPredicate) Containers {
var filtered Containers
for _, c := range containers {
if predicate(c) {
if matches(c, predicates...) {
filtered = append(filtered, c)
}
}

View File

@ -460,7 +460,7 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr
continue
}
waitingFor := containers.filter(isService(dep))
waitingFor := containers.filter(isService(dep), isNotOneOff)
w.Events(containerEvents(waitingFor, progress.Waiting))
if len(waitingFor) == 0 {
if config.Required {