Search in sources :

Example 1 with TagsListing

use of com.epam.pipeline.entity.docker.TagsListing in project cloud-pipeline by epam.

the class DockerClient method getImageTags.

public List<String> getImageTags(String registryPath, String image) {
    String url = String.format(TAGS_LIST, registryPath, image);
    try {
        URI uri = new URI(url);
        HttpEntity entity = getAuthHeaders();
        ResponseEntity<TagsListing> response = getRestTemplate().exchange(uri, HttpMethod.GET, entity, new ParameterizedTypeReference<TagsListing>() {
        });
        if (response.getStatusCode() == HttpStatus.OK) {
            return response.getBody().getTags();
        } else {
            throw new UnexpectedResponseStatusException(response.getStatusCode());
        }
    } catch (URISyntaxException | HttpClientErrorException | UnexpectedResponseStatusException e) {
        LOGGER.error(e.getMessage(), e);
        throw new DockerConnectionException(url, e.getMessage());
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) HttpEntity(org.springframework.http.HttpEntity) TagsListing(com.epam.pipeline.entity.docker.TagsListing) UnexpectedResponseStatusException(com.epam.pipeline.exception.git.UnexpectedResponseStatusException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DockerConnectionException(com.epam.pipeline.exception.docker.DockerConnectionException)

Aggregations

TagsListing (com.epam.pipeline.entity.docker.TagsListing)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 HttpEntity (org.springframework.http.HttpEntity)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1