Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to exec and get output #126

Closed
pawalt opened this issue Jan 4, 2020 · 14 comments
Closed

Add function to exec and get output #126

pawalt opened this issue Jan 4, 2020 · 14 comments
Assignees
Labels
feature New functionality or new behaviors on the existing one good first issue Want to contribute to testcontainers? Start from here hacktoberfest Pull Requests accepted for Hacktoberfest.

Comments

@pawalt
Copy link

pawalt commented Jan 4, 2020

It would be nice to have a function called ExecOutput that would let the user see the output of an exec command. I've got this fully written with testing; I just want to make sure that this is a welcome addition first :)

@mdelapenya
Copy link
Collaborator

I have it already implemented here: #97

@pawalt
Copy link
Author

pawalt commented Jan 5, 2020

Where is it implemented? I don't see anything about execing in a specific container.

@mdelapenya
Copy link
Collaborator

Sorry, typing on mobile... It is a function to retrieve the output of an exec in a container to get the environment variables.

@pawalt
Copy link
Author

pawalt commented Jan 6, 2020

Ah I see. I still think that a command that did the exec with the Docker api like the current exec command but also returned the output from the command would be useful as well. The method I have is of the signature:

func (c *DockerContainer) ExecOut(ctx context.Context, cmd []string) (int, string, error) {

@mdelapenya
Copy link
Collaborator

I'd rather using your function, so I'd rebase my PR and use yours instead

@pawalt
Copy link
Author

pawalt commented Jan 7, 2020

Awesome. Let me polish it off, and I'll PR.

@gianarb
Copy link
Collaborator

gianarb commented Jan 8, 2020

Thanks for doing it! Should we use an io.Reader as return type?!

@pawalt
Copy link
Author

pawalt commented Jan 8, 2020

Yup I'm open to using an io.Reader as the return type. If we're using a reader, do we still want to wait to return until the exec is done, or do we want to allow the user to read off the reader while the command is executing?

@gianarb
Copy link
Collaborator

gianarb commented Jan 8, 2020 via email

@ain-valtin
Copy link

Hey, whats the status of this? Getting the result of the command would be very useful to me, kinda stuck right now with this...

@gianarb
Copy link
Collaborator

gianarb commented Sep 21, 2020

This is a legit and Executing a command is what we should implement in Go.

@gianarb gianarb added hacktoberfest Pull Requests accepted for Hacktoberfest. feature New functionality or new behaviors on the existing one labels Sep 21, 2020
@krisctl
Copy link

krisctl commented Apr 5, 2021

Hello,
Do we have any updates on this? Would like to use this functionality or contribute towards making it work.
Thanks!

@jsirianni
Copy link

This would be very nice

@mdelapenya mdelapenya added the good first issue Want to contribute to testcontainers? Start from here label May 19, 2022
@mdelapenya
Copy link
Collaborator

I think we can close this issue, as it was implemented in #435 and released in v0.14.0: it returns the output reader instead of its string representation, so the consumers will handle it in whatever manner they want.

Please consider that it represents a breaking change

Thanks everybody here for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one good first issue Want to contribute to testcontainers? Start from here hacktoberfest Pull Requests accepted for Hacktoberfest.
Projects
None yet
Development

No branches or pull requests

6 participants