QuayImageRegistry extends AbstractImageRegistry { @Override public List<Tag> getTags(Tool tool) { LOG.info(quayToken.getUsername() + " ======================= Getting tags for: {}================================", tool.getPath()); final String repo = tool.getNamespace() + '/' + tool.getName(); final List<Tag> tags = new ArrayList<>(); final Optional<QuayRepo> toolFromQuay = getToolFromQuay(tool); if (toolFromQuay.isPresent()) { final QuayRepo quayRepo = toolFromQuay.get(); final Map<String, QuayTag> tagsFromRepo = quayRepo.getTags(); final int maxQuayTagsReturnedByRepo = 500; List<QuayTag> quayTags = new ArrayList<>(tagsFromRepo.values()); if (tagsFromRepo.size() == maxQuayTagsReturnedByRepo) { try { quayTags = getAllQuayTags(repo); } catch (ApiException e) { throw new CustomWebApplicationException("Could not get QuayTag", HttpStatus.SC_INTERNAL_SERVER_ERROR); } } for (QuayTag tagItem : quayTags) { try { final Tag tag = convertQuayTagToTag(tagItem, tool); tags.add(tag); } catch (IllegalAccessException | InvocationTargetException ex) { LOG.error(quayToken.getUsername() + " Exception: {}", ex); } } } String repository = tool.getNamespace() + "/" + tool.getName(); updateTagsWithBuildInformation(repository, tags, tool); return tags; } QuayImageRegistry(final Token quayToken); @Override List<Tag> getTags(Tool tool); Optional<QuayRepo> getToolFromQuay(final Tool tool); @Override List<String> getNamespaces(); List<String> getRepositoryNamesFromNamespace(String namespace); @Override List<Tool> getToolsFromNamespace(List<String> namespaces); Tool getToolFromNamespaceAndRepo(String namespace, String repository); @Override void updateAPIToolsWithBuildInformation(List<Tool> apiTools); static String parseReference(String reference); @Override Registry getRegistry(); @Override boolean canConvertToAuto(Tool tool);  }
@Test public void getOver500TagsTest() { Token token = new Token(); token.setContent("fakeQuayTokenBecauseWeDontReallyNeedOne"); QuayImageRegistry quayImageRegistry = new QuayImageRegistry(token); Tool tool = new Tool(); tool.setRegistry("quay.io"); tool.setNamespace("calico"); tool.setName("node"); List<Tag> tags = quayImageRegistry.getTags(tool); int size = tags.size(); Assert.assertTrue("Should be able to get more than the default 500 tags", size > 3838); tags.forEach(tag -> { Assert.assertNotEquals("Image ID should be populated", null, tag.getImageId()); Assert.assertTrue("Images should be populated", tag.getImages().size() > 0); }); Set<String> collect = tags.parallelStream().map(Version::getName).collect(Collectors.toSet()); int distinctSize = collect.size(); Assert.assertEquals("There should be no tags with the same name", size, distinctSize); }