-
-
Notifications
You must be signed in to change notification settings - Fork 492
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 custom registry prefixes at the configuration level #1928
feat: support for custom registry prefixes at the configuration level #1928
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just left a comment that we can address later.
container, err := GenericContainer(ctx, GenericContainerRequest{ | ||
ContainerRequest: ContainerRequest{ | ||
Image: "alpine:latest", | ||
ImageSubstitutors: []ImageSubstitutor{dockerImageSubstitutor{}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this in a previous PR, but wonder in which uses cases do we need more than one substitute. If a substitute is added then the new image name should be pull from the registry, in this case, what happens when more than one is added. If it is not intended then should we deprecate it in a next PR and only accept one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmm I see your point, now with more perspective given the context from this PR. Yeah, makes sense. We just want one function plus the prefix prepender one, in the case it exists.
* 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) ...
What does this PR do?
This PR does two major things:
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX
env var, orhub.image.name.prefix
propertyTestcontainers for Go will automatically apply the prefix to every image that it pulls from Docker Hub.
It will not apply the prefix to:
docker.io
orregistry.hub.docker.com
host part)The PR is adding a custom internal ImageSubstitutor, which is always appended to the user-defined image substitutor functions for a container request, so make sure it's always applied This substitutor will read the configuration to get the prefix, and will append it, when needed, to the image. Unit tests for it has been included.
The PR also improves the docs regarding image substitutors, listing all the images used in the tests.
Finally, the shell script to bump the reaper version has been updated, as the Go file for the Ryuk version has changed.
Why is it important?
First, alignment with the Java behavior. Second, create a consistent experience while pulling images from custom registries.
Related issues