private boolean isImagePullRequired(AbstractRemoteDockerImage image) {
        boolean isAllNamesRequired = isAllNamesRequired();
        boolean isAllTagsRequired  = isAllTagsRequired();
        boolean isAllDigestsRequired = isAllDigestsRequired();

        // All images are required ?
        boolean forcePulling = config.isForcePull();
        // We want to pull everything - so every image is required
        if (isAllNamesRequired && isAllTagsRequired && isAllDigestsRequired && forcePulling) {
            return true;
        }

        // Otherwise we check if the image data is full for specific tag(s)/sha256
        if (!isImageDataValid(image)) {
            return false;
        }

        // Data from the remote image
        List<String> imageTags = image.getImageTags();
        String imageDigest = image.getImageDigest();
        String imageName = image.getRepositoryName();

        if (imageTags == null || imageTags.isEmpty()) {
            logger.info("Image {} with Digest {} - does not have any tags and will be ignored", imageName, imageDigest);
            return false;
        }

        // Data from the config file
        List<String> configImageNames = config.getImageNames();
        List<String> configImageTags = config.getImageTags();
        List<String> configImageDigests = config.getImageDigests();

        boolean isNameMet;
        // Empty configuration = similar to using all names
        if (configImageNames == null) {
            isNameMet = true;
            logger.debug("Configuration - docker.pull.images was not found - using .*.* as default");
        }
        // 'Name' may have a regular expression match
        else {
            isNameMet = isAllNamesRequired || configImageNames.contains(imageName) || isMatchStringInList(imageName, configImageNames);
        }

        // 'Tag' may have a regular expression match
        // 'Tag' should consider pulling/ignoring images with the WS.Scanned tag - according to 'docker.pull.force' flag
        boolean isTagMet = false;
        if (configImageTags == null) {
            isTagMet = true;
            logger.debug("Configuration - docker.pull.tags was not found - using .*.* as default");
        }else {
            for(String currentTag : imageTags) {
                isTagMet = isTagMet || configImageTags.contains(currentTag) || isMatchStringInList(currentTag, configImageTags);
            }
        }

        // 'Digest' cannot have a regular expression match
        boolean isDigestMet = isAllDigestsRequired || configImageDigests.contains(imageDigest);

        // Do not pull images that are already tagged with WS.Scanned tag
        if (!forcePulling) {
            if (imageTags.contains(WS_SCANNED_TAG)) {
                logger.debug("Image {} - was scanned already", imageName);
                isTagMet = false;
            }
        }

        // Is this tag/sha256/name in the required tags/sha256/name list?
        boolean result = isNameMet && isTagMet && isDigestMet ;
        if (!result) {
            logger.debug("Image does not met the requirements: {}", image);
            logger.debug("Name met - {} , Tag met - {} , Digest met - {}", isNameMet, isTagMet, isDigestMet);
        }
        return result;
    }
private boolean isImagePullRequired ( AbstractRemoteDockerImage image ) { boolean isAllNamesRequired = isAllNamesRequired ( ) ; boolean isAllTagsRequired = isAllTagsRequired ( ) ; boolean isAllDigestsRequired = isAllDigestsRequired ( ) ; boolean forcePulling = config . isForcePull ( ) ; if ( isAllNamesRequired && isAllTagsRequired && isAllDigestsRequired && forcePulling ) { return true ; } if ( ! isImageDataValid ( image ) ) { return false ; } List < String > imageTags = image . getImageTags ( ) ; String imageDigest = image . getImageDigest ( ) ; String imageName = image . getRepositoryName ( ) ; if ( imageTags == null || imageTags . isEmpty ( ) ) { logger . info ( "Image {} with Digest {} - does not have any tags and will be ignored" , imageName , imageDigest ) ; return false ; } List < String > configImageNames = config . getImageNames ( ) ; List < String > configImageTags = config . getImageTags ( ) ; List < String > configImageDigests = config . getImageDigests ( ) ; boolean isNameMet ; if ( configImageNames == null ) { isNameMet = true ; logger . debug ( "Configuration - docker.pull.images was not found - using .*.* as default" ) ; } else { isNameMet = isAllNamesRequired || configImageNames . contains ( imageName ) || isMatchStringInList ( imageName , configImageNames ) ; } boolean isTagMet = false ; if ( configImageTags == null ) { isTagMet = true ; logger . debug ( "Configuration - docker.pull.tags was not found - using .*.* as default" ) ; } else { for ( String currentTag : imageTags ) { isTagMet = isTagMet || configImageTags . contains ( currentTag ) || isMatchStringInList ( currentTag , configImageTags ) ; } } boolean isDigestMet = isAllDigestsRequired || configImageDigests . contains ( imageDigest ) ; if ( ! forcePulling ) { if ( imageTags . contains ( WS_SCANNED_TAG ) ) { logger . debug ( "Image {} - was scanned already" , imageName ) ; isTagMet = false ; } } boolean result = isNameMet && isTagMet && isDigestMet ; if ( ! result ) { logger . debug ( "Image does not met the requirements: {}" , image ) ; logger . debug ( "Name met - {} , Tag met - {} , Digest met - {}" , isNameMet , isTagMet , isDigestMet ) ; } return result ; }
TODO: this function should receive manifest image object and check for all values (like date, tags list, etc.)