Skip to content

Commit

Permalink
Issue fabric8io#1185 Prevent docker:save failing when no images are d…
Browse files Browse the repository at this point in the history
…efined.

Signed-off-by: William Rose <[email protected]>
  • Loading branch information
wrosenuance committed Apr 9, 2019
1 parent e454a6e commit 89a6eb9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/io/fabric8/maven/docker/SaveMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ protected void executeInternal(ServiceHub serviceHub) throws DockerAccessExcepti
return;
}
String imageName = getImageName();
if(imageName == null) {
return;
}
String fileName = getFileName(imageName);
ensureSaveDir(fileName);
log.info("Saving image %s to %s", imageName, fileName);
Expand Down Expand Up @@ -101,6 +104,10 @@ private String getImageName() throws MojoExecutionException {
// specify image by name or alias
if (saveName == null && saveAlias == null) {
List<ImageConfiguration> buildImages = getImagesWithBuildConfig(images);
if (buildImages.isEmpty()) {
log.info("No images have a build configuration defined: save skipped");
return null;
}
if (buildImages.size() == 1) {
return buildImages.get(0).getName();
}
Expand Down

0 comments on commit 89a6eb9

Please sign in to comment.