Skip to content

Commit

Permalink
Update ImageName.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Devashishbasu committed Jan 18, 2024
1 parent 298e579 commit e91f186
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,6 @@ private void doValidate() {
String user = inferUser();
String image = user != null ? repository.substring(user.length() + 1) : repository;

//Check repository name length
if (image.length() > 255) {
errors.add(String.format("Repository name '%s' exceeds the maximum allowed length of 255 characters.", image));
}

Object[] checks = new Object[] {
"registry", DOMAIN_REGEXP, registry,
"image", IMAGE_NAME_REGEXP, image,
Expand All @@ -288,7 +283,6 @@ private void doValidate() {

};


for (int i = 0; i < checks.length; i +=3) {
String value = (String) checks[i + 2];
Pattern checkPattern = (Pattern) checks[i + 1];
Expand All @@ -299,6 +293,14 @@ private void doValidate() {
}
}

// Additional validation for repository length
if (repository != null) {
int repositoryLength = repository.length();
if (repositoryLength > 255) {
errors.add(String.format("Repository name '%s' has a length of %d characters, which exceeds the maximum of 255 characters.", repository, repositoryLength));
}
}

if (!errors.isEmpty()) {
StringBuilder buf = new StringBuilder();
buf.append(String.format("Given Docker name '%s' is invalid:%n", getFullName()));
Expand Down Expand Up @@ -362,5 +364,4 @@ private boolean isRegistryValidPathComponent() {
private static final Pattern TAG_REGEXP = Pattern.compile("^[\\w][\\w.-]{0,127}$");

private static final Pattern DIGEST_REGEXP = Pattern.compile("^sha256:[a-z0-9]{32,}$");

}

0 comments on commit e91f186

Please sign in to comment.