Repository navigation
Conversation
Docker's reference parser takes the first path component as a registry when it contains a dot or a colon, is localhost, or is not all lowercase. DockerImageName only knew the first three, so FOO/bar parsed with an empty registry and assertValid() threw.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Why
DockerImageName.parse("FOO/bar")gives an empty registry andassertValid()then throwsIllegalArgumentException. Docker's own reference parser (splitDockerDomainin distribution/reference) takes the first path component as a registry when it contains a dot or a colon, islocalhost, or is not all lowercase, because a repository path is always lowercase.DockerImageNameonly knew the first three rules. The same happens forFoo/bar,LOCALDOMAIN/foooandLOCALDOMAIN/fooo/bar.Refs #12186.
What changes
isRegistry(String firstComponent)inDockerImageNameholds the rule, with the new "not all lowercase" case (toLowerCase(Locale.ROOT)).parseuses, and the name-plus-version one) call it instead of repeating the three-part condition.localhostin its first component (repo/my-name) still has an empty registry; the existingrepo/mynamecases cover this.Tests
DockerImageNameTest: four newParsingcases (FOO/bar,Foo/bar:1.0,LOCALDOMAIN/fooo/bar,LOCALDOMAIN/fooo@sha256:...) and two newValidNamesentries.Parsingalso runs the second constructor for the cases that have a version../gradlew :testcontainers:test --tests '*DockerImageNameTest': 51 tests, all pass. Withcore/src/mainrestored tomain: 51 tests, 6 fail (the new cases)../gradlew :testcontainers:spotlessApply :testcontainers:checkstyleMain :testcontainers:checkstyleTest: passes, no file changed by spotless../gradlew :testcontainers:test --tests 'org.testcontainers.utility.*': 160 tests, 3 fail:ImageNameSubstitutorTest.testImageNameSubstitutorToStringand twoResourceReaperTestcases.ImageNameSubstitutorTestalso fails onmain("replacementImage is null").ResourceReaperTestpasses when run alone with this change; it failed in the run afterImageNameSubstitutorTestin the same JVM (onmain, the same two-class run did not fail it, so I cannot say it is unrelated to ordering with certainty)../gradlew :testcontainers:check(japicmp, javadoc, other modules).Summary by CodeRabbit