-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Normalize image names in prefix substitutor #8509
base: main
Are you sure you want to change the base?
Normalize image names in prefix substitutor #8509
Conversation
@findepi thanks for your contribution, can you please add some docs? |
@eddumelendez thanks for review! |
c002c29
to
78ce06e
Compare
78ce06e
to
64e9271
Compare
If you want your registry to handle both official Docker Hub images (e.g `postgres`) | ||
as well as images from other registries (e.g `mycompany/postgres`), you can use the | ||
`TESTCONTAINERS_HUB_IMAGE_NAME_NORMALIZE` environment variable or the `hub.image.name.normalize` | ||
configuration option. When set to `true`, Testcontainers will normalize the official Docker Hub | ||
image names to start with `library/`. When this option is used, Testcontainers will additionally | ||
disable image compatibility checks done by some containers, so it the compatibility responsibility | ||
is on the user. |
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.
Added this. cc @eddumelendez.
Did i get the env variable name right?
There is automatic conversion from TESTCONTAINERS_HUB_IMAGE_NAME_NORMALIZE to hub.image.name.normalize, right?
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.
yes, the name is correct.
When this option is used, Testcontainers will additionally disable image compatibility checks done by some containers, so it the compatibility responsibility is on the user.
I don't think this is the case because the check compatibility is executed first. Can you please add a test similar to
testcontainers-java/core/src/test/java/org/testcontainers/utility/ImageNameSubstitutorTest.java
Lines 58 to 68 in 00cc0ea
@Test | |
public void testWorksWithoutConfiguredImplementation() { | |
Mockito.doReturn(null).when(TestcontainersConfiguration.getInstance()).getImageSubstitutorClassName(); | |
final ImageNameSubstitutor imageNameSubstitutor = ImageNameSubstitutor.instance(); | |
DockerImageName result = imageNameSubstitutor.apply(DockerImageName.parse("original")); | |
assertThat(result.asCanonicalNameString()) | |
.as("the image has been substituted by default then configured implementations") | |
.isEqualTo("substituted-image:latest"); | |
} |
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 don't think this is the case because the check compatibility is executed first.
that makes sense!
however, when testing this PR internally, i run into some issues until i added "as compatible substitute" call.
is it possible that there are some additional checks somewhere else? sadly, don't have stacktrace now
64e9271
to
4539b80
Compare
The build failed (core)
I will need some guidance, I don't know how to fix it. |
@findepi can you run |
4539b80
to
caee590
Compare
@eddumelendez done! |
CI green this time. Sorry for missing spotless on the previous push. |
core/src/main/java/org/testcontainers/utility/DockerImageName.java
Outdated
Show resolved
Hide resolved
caee590
to
e69a9ce
Compare
I see test failure https://app.circleci.com/pipelines/github/testcontainers/testcontainers-java/11624/workflows/67da8da7-fbdc-42d2-94ab-c6e59c101324/jobs/43677
in https://github.com/trinodb/trino we solved similar failures by bumping the image version, but I am not sure this is the way to go here. @eddumelendez please let me know what do you think about this |
Optionally normalize docker image names to use `library/` prefix when they don't have any namespace at all. This allows for the `PrefixingImageNameSubstitutor` to be used to redirect Docker Hub requests to a private registry without having to apply otherwise redundant changes to the test code.
e69a9ce
to
3baf043
Compare
Optionally normalize docker image names to use
library/
prefix when they don't have any namespace at all. This allows for thePrefixingImageNameSubstitutor
to be used to redirect Docker Hub requests to a private registry without having to apply otherwise redundant changes to the test code.