Skip to content

Commit

Permalink
parsing IPv6 literals support added
Browse files Browse the repository at this point in the history
1.added IPv6 address
2.upated DOMAIN_REGEX for the IPv6 addresses
3.uncommented the related tests

removing issue references

removing issue references
  • Loading branch information
Devashishbasu committed Feb 1, 2024
1 parent 7561af9 commit 6949be6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ private boolean isRegistryValidPathComponent() {

// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L25
private static final String DOMAIN_COMPONENT_REGEXP = "(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])";
private static final String IPV6_ADDRESS_REGEXP = "\\[(?:[a-fA-F0-9:]+)\\]";

// ==========================================================

Expand All @@ -352,7 +353,8 @@ private boolean isRegistryValidPathComponent() {
private static final Pattern IMAGE_NAME_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP + "(?:(?:/" + NAME_COMPONENT_REGEXP + ")+)?");

// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L31
private static final Pattern DOMAIN_REGEXP = Pattern.compile("^" + DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*(?::[0-9]+)?$");
private static final Pattern DOMAIN_REGEXP = Pattern.compile("^(" + IPV6_ADDRESS_REGEXP + "|" + DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*)" +
"(?::[0-9]+)?$");

// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L37
private static final Pattern TAG_REGEXP = Pattern.compile("^[\\w][\\w.-]{0,127}$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class ImageNameDistributionReferenceTest {
"192.168.0.1:8/debian",
"192.168.0.2:25000/debian",
"docker.io/1a3f5e7d9c1b3a5f7e9d1c3b5a7f9e1d3c5b7a9f1e3d5d7c9b1a3f5e7d9c1b3a",
//"[2001:db8::1]/repo", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8:1:2:3:4:5:6]/repo:tag", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8::1]:5000/repo", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8::1]:5000/repo:tag", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8::1]:5000/repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8::1]:5000/repo:tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // https://github.com/eclipse/jkube/issues/2541
//"[2001:db8::]:5000/repo", // https://github.com/eclipse/jkube/issues/2541
//"[::1]:5000/repo", // https://github.com/eclipse/jkube/issues/2541
"[2001:db8::1]/repo",
"[2001:db8:1:2:3:4:5:6]/repo:tag",
"[2001:db8::1]:5000/repo",
"[2001:db8::1]:5000/repo:tag",
"[2001:db8::1]:5000/repo@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"[2001:db8::1]:5000/repo:tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"[2001:db8::]:5000/repo",
"[::1]:5000/repo",
})
void validNames(String name) {
// Given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ImageNameORASReferenceTest {
"registry.example.com/hello-world:v2@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
"localhost:5000/hello-world:v2@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
"127.0.0.1:5000/hello-world:v2@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
//"[::1]:5000/hello-world:v1", // https://github.com/eclipse/jkube/issues/2541
"[::1]:5000/hello-world:v1",
//"registry.example.com/hello-world:@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", // https://github.com/eclipse/jkube/issues/2545
})
void validImageNamesCompatibleWithAll(String name) {
Expand Down

0 comments on commit 6949be6

Please sign in to comment.