compose/pkg
Nicolas De Loof ef54fcaa41 refactor: one handler per container event in monitor.Start, add tests
monitor.Start (cognitive complexity 77) inlined the handling of all
four container actions in the event loop. Each action moves to an
onContainerX handler, with the recurring bits named: watched() (is
this service's container ours to track), notify() (broadcast to
listeners), initialContainers() (seed the tracking set). The loop
drops to complexity 19 and reads as: seed, subscribe, dispatch until
no containers remain. The tracking sets stay explicit parameters so
data flow remains visible.

The monitor had no unit test despite driving up/logs termination; the
refactor is locked by a new suite covering the full lifecycle
(created/recreated/started/restarted/exited, default-name trimming,
exit codes), the restart detection through both engine states
(Restarting, and Running per moby/moby#45538), the already-removed
container on die, service filtering, the no-container fast path,
events stream errors, context cancellation, and exit-code parse
errors.

No behavior change: same events, same ordering, same termination
conditions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-08-18 13:37:48 +02:00
..
api feat(ps): add ENGINE column gated on label presence 2026-08-17 10:34:46 +02:00
bridge lint: replace gocyclo with gocognit 2026-08-18 10:42:37 +02:00
compose refactor: one handler per container event in monitor.Start, add tests 2026-08-18 13:37:48 +02:00
dryrun fix(cp): return non-nil Content from dry-run CopyFromContainer 2026-07-30 11:37:49 +02:00
e2e fix(events): validate service names before subscribing to events 2026-08-18 10:48:59 +02:00
mocks chore(deps): github.com/docker/cli v29.6.0 2026-06-22 09:00:18 +02:00
remote lint: replace gocyclo with gocognit 2026-08-18 10:42:37 +02:00
utils fix: make e2e tests pass reliably locally with Docker Desktop 2026-05-18 10:55:41 +02:00
watch test(watch): cover the permission branches as root 2026-08-11 14:10:40 +02:00