testcontainers-go
testcontainers-go copied to clipboard
[Enhancement]: Modules / Compose - ability to Attach to services when they are started via Up.
Proposal
TLDR: Could we add Up option(s) to allow the cli.StartOption.Attach and AttachTo to be set.
Ref Version v0.31.0
The current implementation of "github.com/testcontainers/testcontainers-go/modules/compose" does not provide a Up option (StackUpOption) to set either the cli.StartOptions.Attach or AttachTo properties. Up func
My proposal is we add 2 extra options to allow the cli.Attach and cli.AttachTo properties to be set. Further these should probably follow the semantics used by the cli docker compose up in that if a non nil Attach value is provided but not a AttachTo the AttachTo should default to all services.
With these options it would then be possible to follow logs within the test containers started via a compose Up. Without this feature the work around is either to poll for logs via a ServiceContainer and repeated Log call (like the log wait strategy does).
I would welcome feedback and suggestions of any other work arounds. If this sounds a sensible way forward happy to contribute with a PR.