-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
feat: support for executing commands in a container with user, workDir and env #1914
Merged
mdelapenya
merged 6 commits into
testcontainers:main
from
mdelapenya:container-exec-options
Nov 17, 2023
Merged
feat: support for executing commands in a container with user, workDir and env #1914
mdelapenya
merged 6 commits into
testcontainers:main
from
mdelapenya:container-exec-options
Nov 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
* main: fix(modules.kafka): Switch to MaxInt for 32-bit support (testcontainers#1923) docs: fix code snippet for image substitution (testcontainers#1918) Add database driver note to SQL Wait strategy docs (testcontainers#1916)
kiview
approved these changes
Nov 17, 2023
mdelapenya
added a commit
to mdelapenya/testcontainers-go
that referenced
this pull request
Nov 17, 2023
* main: feat: support for executing commands in a container with user, workDir and env (testcontainers#1914) fix(modules.kafka): Switch to MaxInt for 32-bit support (testcontainers#1923)
mdelapenya
added a commit
to kuisathaverat/testcontainers-go
that referenced
this pull request
Nov 20, 2023
* main: (31 commits) feat: support for executing commands in a container with user, workDir and env (testcontainers#1914) fix(modules.kafka): Switch to MaxInt for 32-bit support (testcontainers#1923) docs: fix code snippet for image substitution (testcontainers#1918) Add database driver note to SQL Wait strategy docs (testcontainers#1916) Reduce flakiness in ClickHouse tests (testcontainers#1902) lint: enable nonamedreturns (testcontainers#1909) chore: deprecate BindMount APIs (testcontainers#1907) fix(reaper): fix race condition when reusing reapers (testcontainers#1904) feat: Allow the container working directory to be specified (testcontainers#1899) chore: make rabbitmq examples more readable (testcontainers#1905) chore(deps): bump github.com/twmb/franz-go and github.com/twmb/franz-go/pkg/kadm in /modules/redpanda (testcontainers#1896) Fix - respect ContainerCustomizer in neo4j module (testcontainers#1903) chore(deps): bump github.com/nats-io/nkeys and github.com/nats-io/nats.go in /modules/nats (testcontainers#1897) chore: add tests for withNetwork option (testcontainers#1894) chore(deps): bump google.golang.org/grpc and cloud.google.com/go/firestore in /modules/gcloud (testcontainers#1891) chore(deps): bump github.com/aws/aws-sdk-go and github.com/aws/aws-sdk-go-v2/config in /modules/localstack (testcontainers#1892) chore(deps): bump Github actions (testcontainers#1890) chore(deps): bump github.com/shirou/gopsutil/v3 from 3.23.9 to 3.23.10 (testcontainers#1858) chore(deps): bump github.com/hashicorp/consul/api in /examples/consul (testcontainers#1863) chore(deps): bump github.com/IBM/sarama in /modules/kafka (testcontainers#1874) ...
mdelapenya
added a commit
to mdelapenya/testcontainers-go
that referenced
this pull request
Nov 30, 2023
* main: (100 commits) fix: fallback matching of registry authentication config (testcontainers#1927) feat: support customizing the Docker build command (testcontainers#1931) docs: include MongoDB's username and password options into the docs (testcontainers#1930) feat: support for custom registry prefixes at the configuration level (testcontainers#1928) Add username and password functions to mongodb (testcontainers#1910) chore: skip TestContainerLogWithErrClosed as flaky on rootless docker (testcontainers#1925) docs: add some Vault module examples (testcontainers#1825) feat: support for executing commands in a container with user, workDir and env (testcontainers#1914) fix(modules.kafka): Switch to MaxInt for 32-bit support (testcontainers#1923) docs: fix code snippet for image substitution (testcontainers#1918) Add database driver note to SQL Wait strategy docs (testcontainers#1916) Reduce flakiness in ClickHouse tests (testcontainers#1902) lint: enable nonamedreturns (testcontainers#1909) chore: deprecate BindMount APIs (testcontainers#1907) fix(reaper): fix race condition when reusing reapers (testcontainers#1904) feat: Allow the container working directory to be specified (testcontainers#1899) chore: make rabbitmq examples more readable (testcontainers#1905) chore(deps): bump github.com/twmb/franz-go and github.com/twmb/franz-go/pkg/kadm in /modules/redpanda (testcontainers#1896) Fix - respect ContainerCustomizer in neo4j module (testcontainers#1903) chore(deps): bump github.com/nats-io/nkeys and github.com/nats-io/nats.go in /modules/nats (testcontainers#1897) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds some functional options to be applied to the ProcessOptions struct, in order to customise the container exec create response.
For that, and to avoid changing the signature of the Exec method, we are exntending the ProcessOptions struct to accept the User, WorkingDir and Env for a command. We are also adding the options to contribute them to the exec create response.
Because of the previous design, in which the ProcessOptions struct applies to the container exec attach response, we are making the current Multiplexed option to not be executed if its reader is nil. This is needed because we need two loops in the options:
Without changing the API, this is the simplest manner to achieve it.
Finally, it includes a⚠️ breaking change⚠️ in the
Executable
interface: it now includes aOptions()
function that needs to be implemented. This method will allow configuring the exec options added in this PR for theWithStartupCommand
functional option. If your code is implementing Executable, you can embed theExecOptions
struct in your own struct in order to satisfy the interface. Please take a look at the RabbitMQ test types to see examples on how to do it.Why is it important?
Support running commands in the container passing the user, workingDir and the env, which is interesting for users.
Related issues
user
,workingDir
andenv
when executing a command in a container testcontainers-node#668Follow-ups
We should probably update the Executable interface and the RawCommand struct, as it will need a way to receive the process options too.