in core/src/main/java/io/fabric8/maven/core/service/openshift/ImageStreamService.java [185:232]
private String findTagSha(OpenShiftClient client, String imageStreamName, String namespace) throws MojoExecutionException {
ImageStream currentImageStream = null;
for (int i = 0; i < IMAGE_STREAM_TAG_RETRIES; i++) {
if (i > 0) {
log.info("Retrying to find tag on ImageStream %s", imageStreamName);
try {
Thread.sleep(IMAGE_STREAM_TAG_RETRY_TIMEOUT_IN_MILLIS);
} catch (InterruptedException e) {
log.debug("interrupted", e);
}
}
currentImageStream = client.imageStreams().withName(imageStreamName).get();
if (currentImageStream == null) {
continue;
}
ImageStreamStatus status = currentImageStream.getStatus();
if (status == null) {
continue;
}
List<NamedTagEventList> tags = status.getTags();
if (tags == null || tags.isEmpty()) {
continue;
}
// latest tag is the first
TAG_EVENT_LIST:
for (NamedTagEventList list : tags) {
List<TagEvent> items = list.getItems();
if (items == null) {
continue TAG_EVENT_LIST;
}
// latest item is the first
for (TagEvent item : items) {
String image = item.getImage();
if (Strings.isNotBlank(image)) {
log.info("Found tag on ImageStream " + imageStreamName + " tag: " + image);
return image;
}
}
}
}
// No image found, even after several retries:
if (currentImageStream == null) {
throw new MojoExecutionException("Could not find a current ImageStream with name " + imageStreamName + " in namespace " + namespace);
} else {
throw new MojoExecutionException("Could not find a tag in the ImageStream " + imageStreamName);
}
}