def get_manifest_digests(image, registry, insecure=False, dockercfg_path=None,
                         versions=('v1', 'v2', 'v2_list', 'oci', 'oci_index'), require_digest=True):
    """Return manifest digest for image.

    :param image: ImageName, the remote image to inspect
    :param registry: str, URI for registry, if URI schema is not provided,
                          https:// will be used
    :param insecure: bool, when True registry's cert is not verified
    :param dockercfg_path: str, dirname of .dockercfg location
    :param versions: tuple, which manifest schema versions to fetch digest
    :param require_digest: bool, when True exception is thrown if no digest is
                                 set in the headers.

    :return: dict, versions mapped to their digest
    """

    registry_session = RegistrySession(registry, insecure=insecure, dockercfg_path=dockercfg_path)

    digests = {}
    # If all of the media types return a 404 NOT_FOUND status, then we rethrow
    # an exception, if all of the media types fail for some other reason - like
    # bad headers - then we return a ManifestDigest object with no digests.
    # This is interesting for the Pulp "retry until the manifest shows up" case.
    all_not_found = True
    saved_not_found = None
    for version in versions:
        media_type = get_manifest_media_type(version)
        response, saved_not_found = get_manifest(image, registry_session, version)

        if saved_not_found is None:
            all_not_found = False

        if not response:
            continue
        # set it to truthy value so that koji_import would know pulp supports these digests
        digests[version] = True

        if not response.headers.get('Docker-Content-Digest'):
            logger.warning('Unable to fetch digest for %s, no Docker-Content-Digest header',
                           media_type)
            continue

        digests[version] = response.headers['Docker-Content-Digest']
        context = '/'.join([x for x in [image.namespace, image.repo] if x])
        tag = image.tag
        logger.debug('Image %s:%s has %s manifest digest: %s',
                     context, tag, version, digests[version])

    if not digests:
        if all_not_found and len(versions) > 0:
            raise saved_not_found
        if require_digest:
            raise RuntimeError('No digests found for {}'.format(image))

    return ManifestDigest(**digests)
Return manifest digest for image.

    :param image: ImageName, the remote image to inspect
    :param registry: str, URI for registry, if URI schema is not provided,
                          https:// will be used
    :param insecure: bool, when True registry's cert is not verified
    :param dockercfg_path: str, dirname of .dockercfg location
    :param versions: tuple, which manifest schema versions to fetch digest
    :param require_digest: bool, when True exception is thrown if no digest is
                                 set in the headers.

    :return: dict, versions mapped to their digest