use of com.epam.pipeline.entity.docker.RawImageDescription in project cloud-pipeline by epam.
the class DockerDateUtilsTest method shouldCalculateLatestAndEarliestDateTimeProperly.
@Test
public void shouldCalculateLatestAndEarliestDateTimeProperly() {
HistoryEntry entryWithEarliestDate = new HistoryEntry();
entryWithEarliestDate.setV1Compatibility(EARLIEST_DATE);
HistoryEntry entryWithLatestDate = new HistoryEntry();
entryWithLatestDate.setV1Compatibility(LATEST_DATE);
HistoryEntry entryWithShortDate = new HistoryEntry();
entryWithShortDate.setV1Compatibility(SHORT_DATE);
RawImageDescription description = new RawImageDescription();
description.setHistory(Arrays.asList(entryWithEarliestDate, entryWithLatestDate, entryWithShortDate));
assertThat(DockerDateUtils.getEarliestDate(description).toInstant().atZone(ZoneOffset.UTC).getMinute()).isEqualTo(EARLIEST_MINUTES);
assertThat(DockerDateUtils.getLatestDate(description).toInstant().atZone(ZoneOffset.UTC).getMinute()).isEqualTo(LATEST_MINUTES);
}
use of com.epam.pipeline.entity.docker.RawImageDescription in project cloud-pipeline by epam.
the class DockerClient method getImageDescription.
public ImageDescription getImageDescription(DockerRegistry registry, String imageName, String tag) {
RawImageDescription rawImage = getRawImageDescription(registry, imageName, tag, getAuthHeaders());
rawImage.setRegistry(registry.getId());
return rawImage.getImageDescription();
}
use of com.epam.pipeline.entity.docker.RawImageDescription in project cloud-pipeline by epam.
the class DockerClient method getRawImageDescription.
private RawImageDescription getRawImageDescription(DockerRegistry registry, String imageName, String tag, HttpEntity headers) {
String url = String.format(IMAGE_DESCRIPTION_URL, registry.getPath(), imageName, tag);
try {
URI uri = new URI(url);
ResponseEntity<RawImageDescription> response = getRestTemplate().exchange(uri, HttpMethod.GET, headers, new ParameterizedTypeReference<RawImageDescription>() {
});
if (response.getStatusCode() == HttpStatus.OK) {
return response.getBody();
} else {
throw new UnexpectedResponseStatusException(response.getStatusCode());
}
} catch (URISyntaxException | UnexpectedResponseStatusException e) {
LOGGER.error(e.getMessage(), e);
throw new DockerConnectionException(url, e.getMessage());
}
}
Aggregations