testcontainers-go icon indicating copy to clipboard operation
testcontainers-go copied to clipboard

Customise stdout and stderr for compose commands

Open byrnedo opened this issue 3 years ago • 7 comments

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?

byrnedo avatar Jan 19 '22 12:01 byrnedo

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).

mdelapenya avatar Jan 20 '22 06:01 mdelapenya

Would this implementation satisfy your needs? #420

mdelapenya avatar Mar 31 '22 08:03 mdelapenya

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 avatar May 17 '22 08:05 edebernis

@edebernis we merged https://github.com/testcontainers/testcontainers-go/pull/420. Is that enough for your use case?

mdelapenya avatar May 19 '22 09:05 mdelapenya

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.

edebernis avatar May 19 '22 09:05 edebernis

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 :)

mdelapenya avatar May 19 '22 09:05 mdelapenya

Given this comment by @edebernis https://github.com/testcontainers/testcontainers-go/pull/470#issuecomment-1289608644, do you think we can close this issue?

mdelapenya avatar Mar 01 '23 06:03 mdelapenya

Closing as stale, please feel free to reopen if you need anything else from here.

Thanks!

mdelapenya avatar Apr 22 '24 11:04 mdelapenya