private String getImageName(ServiceSpec serviceSpec, ImageCleanUpPolicy cleanUpPolicy)
            throws HyscaleException {
        Image image = serviceSpec.get(HyscaleSpecFields.image, Image.class);
        switch (cleanUpPolicy) {
        case DELETE_AFTER_BUILD:
            return ImageUtil.getImage(image);
        case PRESERVE_N_RECENTLY_USED:
            return ImageUtil.getImageWithoutTag(image);
        case DELETE_ALL:
            return null;
        default:
            return ImageUtil.getImage(image);
        }

    }
This class is responsible for cleaning up local images
It uses User defined cleanup policy to clean up respective images
The images are fetched and cleaned up based on available docker client
image-builder/builder-services/src/main/java/io/hyscale/builder/services/cleanup/ImageCleanUpProcessor.java