@Test public void testGetStatedImagesFilteredByOperatingSystems() throws CloudbreakImageCatalogException, IOException { setupUserProfileService(); setupImageCatalogProvider(DEFAULT_CATALOG_URL, DEV_CATALOG_FILE); Set<String> operatingSystems = new HashSet<>(Arrays.asList("redhat7", "redhat6", "amazonlinux2")); ImageFilter imageFilter = new ImageFilter(imageCatalog, Set.of("AWS"), null, true, operatingSystems, null); StatedImages images = underTest.getStatedImagesFilteredByOperatingSystems(imageFilter, i -> true); boolean allMatch = images.getImages().getBaseImages().stream().allMatch(image -> operatingSystems.contains(image.getOsType())); assertTrue("All images should be based on supported OS", allMatch); }
public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException { Set<String> platforms = imageFilter.getPlatforms(); Set<String> operatingSystems = imageFilter.getOperatingSystems(); ImageCatalog imageCatalog = imageFilter.getImageCatalog(); boolean baseImageEnabled = imageFilter.isBaseImageEnabled(); StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null)); if (!CollectionUtils.isEmpty(operatingSystems)) { Images rawImages = images.getImages(); List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate); List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate); images = statedImages(new Images(baseImages, cdhImages, rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName()); } return images; }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException { Set<String> platforms = imageFilter.getPlatforms(); Set<String> operatingSystems = imageFilter.getOperatingSystems(); ImageCatalog imageCatalog = imageFilter.getImageCatalog(); boolean baseImageEnabled = imageFilter.isBaseImageEnabled(); StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null)); if (!CollectionUtils.isEmpty(operatingSystems)) { Images rawImages = images.getImages(); List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate); List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate); images = statedImages(new Images(baseImages, cdhImages, rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName()); } return images; } }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException { Set<String> platforms = imageFilter.getPlatforms(); Set<String> operatingSystems = imageFilter.getOperatingSystems(); ImageCatalog imageCatalog = imageFilter.getImageCatalog(); boolean baseImageEnabled = imageFilter.isBaseImageEnabled(); StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null)); if (!CollectionUtils.isEmpty(operatingSystems)) { Images rawImages = images.getImages(); List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate); List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate); images = statedImages(new Images(baseImages, cdhImages, rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName()); } return images; }  }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException { Set<String> platforms = imageFilter.getPlatforms(); Set<String> operatingSystems = imageFilter.getOperatingSystems(); ImageCatalog imageCatalog = imageFilter.getImageCatalog(); boolean baseImageEnabled = imageFilter.isBaseImageEnabled(); StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null)); if (!CollectionUtils.isEmpty(operatingSystems)) { Images rawImages = images.getImages(); List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate); List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate); images = statedImages(new Images(baseImages, cdhImages, rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName()); } return images; }  @Override Set<ImageCatalog> findAllByWorkspaceId(Long workspaceId); ImageCatalog delete(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); @Override Set<ImageCatalog> findAllByWorkspace(Workspace workspace); ImageCatalog createForLoggedInUser(ImageCatalog imageCatalog, Long workspaceId, String accountId, String creator); ImageCatalog get(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); ImageCatalog findByResourceCrn(String resourceCrn); Images getImagesByCatalogName(Long workspaceId, String catalogName, String stackName, String platform); Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems); StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getLatestBaseImageDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getImagePrewarmedDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImages getImages(Long workspaceId, String name, String provider); StatedImages getImages(Long workspaceId, String name, Set<String> providers); StatedImage getImage(String imageId); StatedImage getImage(String catalogUrl, String catalogName, String imageId); StatedImage getImageByCatalogName(Long workspaceId, String imageId, String catalogName); ImageCatalog delete(Long workspaceId, String name); Set<ImageCatalog> deleteMultiple(Long workspaceId, Set<String> names); ImageCatalog get(Long workspaceId, String name); boolean isEnvDefault(String name); ImageCatalog update(Long workspaceId, ImageCatalog source); StatedImages getImages(ImageFilter imageFilter); Images propagateImagesIfRequested(Long workspaceId, String name, Boolean withImages); boolean baseImageEnabled(); @Nonnull ImageCatalog getDefaultImageCatalog(User user); String getDefaultImageCatalogName(User user); String getImageDefaultCatalogUrl(User user); @Override WorkspaceResourceRepository<ImageCatalog, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); List<ImageCatalog> getDefaultImageCatalogs(); @Override AuthorizationResourceType getResourceType(); }
ImageCatalogService extends AbstractWorkspaceAwareResourceService<ImageCatalog> implements ResourceBasedCrnProvider { public StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate) throws CloudbreakImageCatalogException { Set<String> platforms = imageFilter.getPlatforms(); Set<String> operatingSystems = imageFilter.getOperatingSystems(); ImageCatalog imageCatalog = imageFilter.getImageCatalog(); boolean baseImageEnabled = imageFilter.isBaseImageEnabled(); StatedImages images = getImages(new ImageFilter(imageCatalog, platforms, cbVersion, baseImageEnabled, null, null)); if (!CollectionUtils.isEmpty(operatingSystems)) { Images rawImages = images.getImages(); List<Image> baseImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getBaseImages(), operatingSystems, imageFilterPredicate); List<Image> cdhImages = filterImagesByOperatingSystemsAndPackageVersion(rawImages.getCdhImages(), operatingSystems, imageFilterPredicate); images = statedImages(new Images(baseImages, cdhImages, rawImages.getSuppertedVersions()), images.getImageCatalogUrl(), images.getImageCatalogName()); } return images; }  @Override Set<ImageCatalog> findAllByWorkspaceId(Long workspaceId); ImageCatalog delete(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); @Override Set<ImageCatalog> findAllByWorkspace(Workspace workspace); ImageCatalog createForLoggedInUser(ImageCatalog imageCatalog, Long workspaceId, String accountId, String creator); ImageCatalog get(NameOrCrn imageCatalogNameOrCrn, Long workspaceId); ImageCatalog findByResourceCrn(String resourceCrn); Images getImagesByCatalogName(Long workspaceId, String catalogName, String stackName, String platform); Images getImagesFromDefault(Long workspaceId, String stackName, String platform, Set<String> operatingSystems); StatedImages getStatedImagesFilteredByOperatingSystems(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getLatestBaseImageDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImage getImagePrewarmedDefaultPreferred(ImageFilter imageFilter, Predicate<Image> imageFilterPredicate); StatedImages getImages(Long workspaceId, String name, String provider); StatedImages getImages(Long workspaceId, String name, Set<String> providers); StatedImage getImage(String imageId); StatedImage getImage(String catalogUrl, String catalogName, String imageId); StatedImage getImageByCatalogName(Long workspaceId, String imageId, String catalogName); ImageCatalog delete(Long workspaceId, String name); Set<ImageCatalog> deleteMultiple(Long workspaceId, Set<String> names); ImageCatalog get(Long workspaceId, String name); boolean isEnvDefault(String name); ImageCatalog update(Long workspaceId, ImageCatalog source); StatedImages getImages(ImageFilter imageFilter); Images propagateImagesIfRequested(Long workspaceId, String name, Boolean withImages); boolean baseImageEnabled(); @Nonnull ImageCatalog getDefaultImageCatalog(User user); String getDefaultImageCatalogName(User user); String getImageDefaultCatalogUrl(User user); @Override WorkspaceResourceRepository<ImageCatalog, Long> repository(); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); List<ImageCatalog> getDefaultImageCatalogs(); @Override AuthorizationResourceType getResourceType(); static final String UNDEFINED; static final String CDP_DEFAULT_CATALOG_NAME; }