Skip to content

Commit

Permalink
fix(imagetagging): asset foundImage count >= upstreamImageIds count (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
asher authored Mar 28, 2019
1 parent 9cb3276 commit 0d25d50
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Map;

import static java.lang.String.format;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;

public abstract class ImageTagger {
Expand Down Expand Up @@ -84,7 +85,12 @@ protected Collection findImages(Collection<String> imageNames, Collection<String
String upstreamImageName = (String) allMatchedImages.get(0).get("imageName");
imageNames.add(upstreamImageName);

log.info(format("Found upstream image '%s' (executionId: %s)", upstreamImageName, stage.getExecution().getId()));
log.info(
format("Found upstream image '%s' for imageId '%s' (executionId: %s)",
upstreamImageName,
upstreamImageId,
stage.getExecution().getId())
);
}
}

Expand All @@ -102,6 +108,14 @@ protected Collection findImages(Collection<String> imageNames, Collection<String
foundImages.add(objectMapper.convertValue(matchedImage, matchedImageType));
}

if (foundImages.size() < upstreamImageIds.size()) {
throw new ImageNotFound(
format("Only found %d images to tag but %d were specified upstream (%s)",
foundImages.size(),
upstreamImageIds.size(),
imageNames
), true);
}
return foundImages;
}

Expand Down

0 comments on commit 0d25d50

Please sign in to comment.