Search in sources :

Example 1 with DockerTagModel

use of com.synopsys.integration.alert.update.model.DockerTagModel in project hub-alert by blackducksoftware.

the class UpdateChecker method getLatestAvailableTag.

private Optional<VersionDateModel> getLatestAvailableTag(DockerTagRetriever dockerTagRetriever, boolean isProduction) {
    DockerTagsResponseModel tagsResponseModel = dockerTagRetriever.getTagsModel();
    List<DockerTagModel> tags = new LinkedList<>();
    while (!tagsResponseModel.isEmpty()) {
        tags.addAll(tagsResponseModel.getResults());
        tagsResponseModel = dockerTagRetriever.getNextPage(tagsResponseModel);
    }
    return tags.stream().filter(dockerTagModel -> {
        if (isProduction) {
            return isProductionVersion(dockerTagModel.getName());
        }
        return true;
    }).map(dockerTagModel -> new VersionDateModel(dockerTagModel.getName(), dockerTagModel.getLastUpdated())).min(versionDateModelComparator());
}
Also used : DockerTagsResponseModel(com.synopsys.integration.alert.update.model.DockerTagsResponseModel) DOCKER_DATE_FORMAT(com.synopsys.integration.alert.common.util.DateUtils.DOCKER_DATE_FORMAT) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) IntLogger(com.synopsys.integration.log.IntLogger) AboutReader(com.synopsys.integration.alert.web.api.about.AboutReader) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) Gson(com.google.gson.Gson) ParseException(java.text.ParseException) LinkedList(java.util.LinkedList) AboutModel(com.synopsys.integration.alert.web.api.about.AboutModel) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) DockerTagModel(com.synopsys.integration.alert.update.model.DockerTagModel) List(java.util.List) Component(org.springframework.stereotype.Component) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) NumberUtils(org.apache.commons.lang3.math.NumberUtils) Optional(java.util.Optional) DockerTagsResponseModel(com.synopsys.integration.alert.update.model.DockerTagsResponseModel) Comparator(java.util.Comparator) DateUtils.parseDate(com.synopsys.integration.alert.common.util.DateUtils.parseDate) ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) DockerTagModel(com.synopsys.integration.alert.update.model.DockerTagModel) LinkedList(java.util.LinkedList)

Example 2 with DockerTagModel

use of com.synopsys.integration.alert.update.model.DockerTagModel in project hub-alert by blackducksoftware.

the class DockerTagRetrieverTest method createMockResponse.

private Response createMockResponse() throws IntegrationException {
    Response mockResponse = Mockito.mock(Response.class);
    List<DockerTagModel> tagModels = List.of(createDockerTagModel("1.0.0"), createDockerTagModel("1.0.1"));
    DockerTagsResponseModel mockDockerTagsResponseModel = new DockerTagsResponseModel(TAGS_COUNT, null, null, tagModels);
    String jsonString = gson.toJson(mockDockerTagsResponseModel);
    Mockito.when(mockResponse.getContentString()).thenReturn(jsonString);
    Mockito.doNothing().when(mockResponse).throwExceptionForError();
    return mockResponse;
}
Also used : Response(com.synopsys.integration.rest.response.Response) DockerTagsResponseModel(com.synopsys.integration.alert.update.model.DockerTagsResponseModel) DockerTagModel(com.synopsys.integration.alert.update.model.DockerTagModel)

Aggregations

DockerTagModel (com.synopsys.integration.alert.update.model.DockerTagModel)2 DockerTagsResponseModel (com.synopsys.integration.alert.update.model.DockerTagsResponseModel)2 Gson (com.google.gson.Gson)1 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)1 DOCKER_DATE_FORMAT (com.synopsys.integration.alert.common.util.DateUtils.DOCKER_DATE_FORMAT)1 DateUtils.parseDate (com.synopsys.integration.alert.common.util.DateUtils.parseDate)1 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)1 AboutModel (com.synopsys.integration.alert.web.api.about.AboutModel)1 AboutReader (com.synopsys.integration.alert.web.api.about.AboutReader)1 IntLogger (com.synopsys.integration.log.IntLogger)1 Slf4jIntLogger (com.synopsys.integration.log.Slf4jIntLogger)1 IntHttpClient (com.synopsys.integration.rest.client.IntHttpClient)1 ProxyInfo (com.synopsys.integration.rest.proxy.ProxyInfo)1 Response (com.synopsys.integration.rest.response.Response)1 ParseException (java.text.ParseException)1 OffsetDateTime (java.time.OffsetDateTime)1 Comparator (java.util.Comparator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1