Skip to content
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

ImageName should be able to parse image names with IPv6 address literals #2603

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6949be6
parsing IPv6 literals support added
Devashishbasu Feb 1, 2024
16e07c5
test : Add TestHttpBuildPackArtifactsServer in jkube-kit/common
rohanKanojia Jan 31, 2024
302b2b7
fix: remove KubernetesResourceUtil.ensureHasPort unnecessary 'null' c…
ArunErram Feb 1, 2024
dfa0486
test(jkube-kit-enricher-api): Replaced org.mockito.Mockito references…
ShantKhatri Feb 1, 2024
b5dbf12
test(jkube-kit-enricher-api): Replaced org.mockito references from En…
ShantKhatri Feb 1, 2024
b9515f5
Implemented suggested changes by sonarcloud
Devashishbasu Feb 2, 2024
708dff2
fix: SecretEnricher.getSecretsFromXmlConfig returns Collections.empty…
sankritimishra Feb 2, 2024
7a60b29
feat(helm): add helm-java dependency
manusa Feb 2, 2024
70b6723
test(jkube-kit-build-api): Removed mock statements from AssemblyManag…
ShantKhatri Feb 2, 2024
44bbcdb
test: DefaultControllerEnricherCreateTest.setUp The declared Exceptio…
Ravinder-coder Feb 2, 2024
81fed6a
updated the suggested changes
Devashishbasu Feb 3, 2024
4a874ff
test: remove redundant throws in IngressEnricherTest.setUp (#2618)
AmitPatil05 Feb 5, 2024
51a80d3
chore(deps): Bump org.apache.maven:maven-core in /jkube-kit/parent
dependabot[bot] Feb 2, 2024
ed4154b
fix (jkube-kit/enricher) : WellKnownLabelEnricher also considers labe…
rohanKanojia Jan 25, 2024
6cd411a
review: Well Known Label Enricher
manusa Feb 5, 2024
ed0cc80
SecretEnricher getSecretsFromXmlConfig should return Collections.empt…
sankritimishra Feb 5, 2024
c162993
fix(quickstarts/maven): Removed unused run configuration (#2620)
ShantKhatri Feb 5, 2024
d38642f
test : Add TestHttpBuildPackArtifactsServer in jkube-kit/common
rohanKanojia Jan 31, 2024
0db5cce
feat (jkube-kit/config/service) : Add BuildPackBuildService (#2493)
rohanKanojia Dec 6, 2023
005241e
review: BuildPackBuildService
manusa Feb 5, 2024
13e01f8
feat: HelmService provides linting features
manusa Feb 5, 2024
d828cd2
feat: helm lint exposed in Gradle and Maven plugins
manusa Feb 6, 2024
da8eb46
adding suggested changes by rohan sir
Devashishbasu Feb 8, 2024
c142522
parsing IPv6 literals support added
Devashishbasu Feb 1, 2024
ef6583e
Merge branch 'ImageName-should-be-able-to-parse-image-names-with-IPv6…
Devashishbasu Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void doValidate() {
String user = inferUser();
String image = user != null ? repository.substring(user.length() + 1) : repository;
Object[] checks = new Object[] {
"registry", DOMAIN_REGEXP, registry,
"registry", REGISTRY_REGEXP, registry,
"image", IMAGE_NAME_REGEXP, image,
"user", NAME_COMP_REGEXP, user,
"tag", TAG_REGEXP, tag,
Expand Down Expand Up @@ -323,7 +323,7 @@ private void parseComponentsBeforeTag(String rest) {
}

private boolean isValidDomain(String str) {
return containsPeriodOrColon(str) && DOMAIN_REGEXP.matcher(str).matches();
return containsPeriodOrColon(str) && REGISTRY_REGEXP.matcher(str).matches();
}

private boolean isRegistryValidPathComponent() {
Expand All @@ -343,6 +343,9 @@ 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])";

//https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L91
private static final String IPV6_ADDRESS_REGEXP = "\\[[a-fA-F0-9:]+\\]";

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

// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L18
Expand All @@ -351,8 +354,13 @@ private boolean isRegistryValidPathComponent() {
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L53
private static final Pattern IMAGE_NAME_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP + "(?:(?:/" + NAME_COMPONENT_REGEXP + ")+)?");

// https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L65
private static final String OPTIONAL_PORT_REGEXP = "(?::[0-9]+)?";
private static final String DOMAIN_NAME_REGEXP = DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final String DOMAIN_NAME_REGEXP = DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*";
// https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L99
private static final String DOMAIN_NAME_REGEXP = DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*";

private static final String REGISTRY_HOST_REGEXP = "^(?:" + IPV6_ADDRESS_REGEXP + "|" + DOMAIN_NAME_REGEXP + ")";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final String REGISTRY_HOST_REGEXP = "^(?:" + IPV6_ADDRESS_REGEXP + "|" + DOMAIN_NAME_REGEXP + ")";
// https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L106
private static final String REGISTRY_HOST_REGEXP = "^(?:" + IPV6_ADDRESS_REGEXP + "|" + DOMAIN_NAME_REGEXP + ")";


// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L31
Copy link
Member

@rohanKanojia rohanKanojia Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update the comment pointing to regexp source too?

private static final Pattern DOMAIN_REGEXP = Pattern.compile("^" + DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*(?::[0-9]+)?$");
private static final Pattern REGISTRY_REGEXP = Pattern.compile(REGISTRY_HOST_REGEXP + OPTIONAL_PORT_REGEXP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final Pattern REGISTRY_REGEXP = Pattern.compile(REGISTRY_HOST_REGEXP + OPTIONAL_PORT_REGEXP);
// https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L110
private static final Pattern REGISTRY_REGEXP = Pattern.compile(REGISTRY_HOST_REGEXP + OPTIONAL_PORT_REGEXP);


// 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