Search in sources :

Example 1 with RawImageDescription

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);
}
Also used : RawImageDescription(com.epam.pipeline.entity.docker.RawImageDescription) HistoryEntry(com.epam.pipeline.entity.docker.HistoryEntry) Test(org.junit.Test)

Example 2 with RawImageDescription

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();
}
Also used : RawImageDescription(com.epam.pipeline.entity.docker.RawImageDescription)

Example 3 with RawImageDescription

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());
    }
}
Also used : RawImageDescription(com.epam.pipeline.entity.docker.RawImageDescription) UnexpectedResponseStatusException(com.epam.pipeline.exception.git.UnexpectedResponseStatusException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DockerConnectionException(com.epam.pipeline.exception.docker.DockerConnectionException)

Aggregations

RawImageDescription (com.epam.pipeline.entity.docker.RawImageDescription)3 HistoryEntry (com.epam.pipeline.entity.docker.HistoryEntry)1 DockerConnectionException (com.epam.pipeline.exception.docker.DockerConnectionException)1 UnexpectedResponseStatusException (com.epam.pipeline.exception.git.UnexpectedResponseStatusException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Test (org.junit.Test)1