Customise stdout and stderr for compose commands
Hi,
I'd like to be able to send all the stdout or stderr for a compose .Invoke() to an io.Writer of my choosing. Is there a way to do that currently?
Hi @byrnedo, thanks for your question :) I'd say this is currently not possible (see https://github.com/testcontainers/testcontainers-go/blob/fea599d3c9048f1fd704846541d17951f1252839/compose.go#L266-L267), although it could be considered a nice feature request if you explain your use case and possible implementations more in details (maybe here in this issue).
Would this implementation satisfy your needs? #420
Hey ! I found myself having the same need than @byrnedo.
Ideally, we should be able to pass options to the LocalDockerCompose struct to allow specifying custom pipes for command stdin, stdout and stderr.
Something like this:
func WithStdinPipe(pipe io.Reader) DockerCompose
func WithStdoutPipe(pipe io.Writer) DockerCompose
func WithStderrPipe(pipe io.Writer) DockerCompose
Do you want me to implement a PR with this design ?
Thanks !
@edebernis we merged https://github.com/testcontainers/testcontainers-go/pull/420. Is that enough for your use case?
with #420, the command outputs are still piped to standards (stdout / stderr).
IMHO, it would be better to allow the user to override this behavior by specifing custom io.Writer / io.Reader to store command outputs. And use stdout / stderr by default if nothing is specified.
with #420, the command outputs are still piped to standards (stdout / stderr).
IMHO, it would be better to allow the user to override this behavior by specifing custom io.Writer / io.Reader to store command outputs. And use stdout / stderr by default if nothing is specified.
We will be more than happy to review a PR :)
Given this comment by @edebernis https://github.com/testcontainers/testcontainers-go/pull/470#issuecomment-1289608644, do you think we can close this issue?
Closing as stale, please feel free to reopen if you need anything else from here.
Thanks!