Skip to content

Commit

Permalink
feat(jkube-kit-config-service): suggest to rename the image name
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivangMishra committed Sep 1, 2023
1 parent 89ee072 commit 528af16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Expand Up @@ -46,6 +46,16 @@ private interface ImageConfigurationProcessor {
void process(ImageConfiguration imageConfiguration) throws JKubeServiceException;
}

protected String getHintFromException(Exception ex) {
String message = "Error while trying to push the image: " + ex.getMessage();

Check warning on line 50 in jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java

View check run for this annotation

Codecov / codecov/patch

jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java#L50

Added line #L50 was not covered by tests
if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) {
message += "\nPossible issues: invalid credentials or incorrect image name or registry." +

Check warning on line 52 in jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java

View check run for this annotation

Codecov / codecov/patch

jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java#L52

Added line #L52 was not covered by tests
"\nHint: Check your credentials." +
"\nHint: Image name can be modified with the jkube.generator.name property";
}
return message;

Check warning on line 56 in jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java

View check run for this annotation

Codecov / codecov/patch

jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/AbstractImageBuildService.java#L56

Added line #L56 was not covered by tests
}

private void processImage(ImageConfigurationProcessor imageConfigurationConsumer, String skipMessage, ImageConfiguration... imageConfigurations) throws JKubeServiceException {
if (imageConfigurations != null) {
for (ImageConfiguration imageConfiguration : imageConfigurations) {
Expand Down
Expand Up @@ -70,12 +70,7 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie
try {
dockerServices.getRegistryService().pushImage(imageConfiguration, retries, registryConfig, skipTag);
} catch (IOException ex) {
String message = "Error while trying to push the image: " + ex.getMessage();
if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) {
message += "\nPossible issue: wrong image name or registry." +
"\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name";
}
throw new JKubeServiceException(message, ex);
throw new JKubeServiceException(getHintFromException(ex), ex);

Check warning on line 73 in jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java

View check run for this annotation

Codecov / codecov/patch

jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/DockerBuildService.java#L73

Added line #L73 was not covered by tests
}
}

Expand Down
Expand Up @@ -116,12 +116,7 @@ protected void pushSingleImage(ImageConfiguration imageConfiguration, int retrie
log
);
} catch (Exception ex) {
String message = "Error when push JIB image: " + ex.getMessage();
if(ex.getMessage().contains("denied") || ex.getMessage().contains("unauthorized")) {
message += "\nPossible issue: wrong image name or registry." +
"\nHint: Rename image name or registry with the jkube.generator.name property = registry name and user name and image name";
}
throw new JKubeServiceException(message, ex);
throw new JKubeServiceException(getHintFromException(ex), ex);

Check warning on line 119 in jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java

View check run for this annotation

Codecov / codecov/patch

jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/JibBuildService.java#L119

Added line #L119 was not covered by tests
}
}

Expand Down

0 comments on commit 528af16

Please sign in to comment.