compose-go/internal/generate/containerspec
Nicolas De Loof 11feead015 feat: resolve pre_start inheritance at load time
The pre_start hook specification used to be completed by the runtime
(docker/compose merged the service's container specification under the
hook's, through this module's own merge machinery). The resolution now
happens during loading, in the normalization phase: the loaded model
carries hooks already completed with every inherited attribute, so any
consumer — compose config included — sees the specification a hook
actually runs with.

The merge follows the compose rules, applied post-canonicalization by
wrapping the hook as a service entry so the per-attribute mergers
match: the hook's declarations win on conflicts, collections merge,
and the sequence merge's strictly-identical-entry dedup makes the
resolution idempotent — loading an already-resolved model resolves to
the same hooks, so config round-trips stay stable.

The inherited side is filtered to container-spec attributes (derived
from the ContainerSpec type by reflection, so the filter cannot drift
from the model), minus volumes: mounts inherit at runtime through
volumes_from, the only mechanism able to share the parent's anonymous
and image volumes. This subsumes the image-only inheritance of
compose-spec#647 (inheritPreStartImage).

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
History 2026-09-10 17:44:16 +02:00
..
main.go feat: resolve pre_start inheritance at load time 2026-09-10 17:44:16 +02:00