def requestCheckDockerIo(origAppliance, imageName, tag):
    """
    Checks docker.io to see if an image exists using the requests library.

    URL is based on the docker v2 schema.  Requires that an access token be fetched first.

    :param str origAppliance: The full url of the docker image originally
                              specified by the user (or the default).  e.g. "ubuntu:latest"
    :param str imageName: The image, including path and excluding the tag. e.g. "ubuntu"
    :param str tag: The tag used at that docker image's registry.  e.g. "latest"
    :return: Return True if match found.  Raise otherwise.
    """
    # only official images like 'busybox' or 'ubuntu'
    if '/' not in imageName:
        imageName = 'library/' + imageName

    token_url = 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:{repo}:pull'.format(repo=imageName)
    requests_url = 'https://registry-1.docker.io/v2/{repo}/manifests/{tag}'.format(repo=imageName, tag=tag)

    token = requests.get(token_url)
    jsonToken = token.json()
    bearer = jsonToken["token"]
    response = requests.head(requests_url, headers={'Authorization': 'Bearer {}'.format(bearer)})
    if not response.ok:
        raise ApplianceImageNotFound(origAppliance, requests_url, response.status_code)
    else:
        return origAppliance
def requestCheckDockerIo ( origAppliance , imageName , tag ) : if '/' not in imageName : imageName = 'library/' + imageName token_url = 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:{repo}:pull' . format ( repo = imageName ) requests_url = 'https://registry-1.docker.io/v2/{repo}/manifests/{tag}' . format ( repo = imageName , tag = tag ) token = requests . get ( token_url ) jsonToken = token . json ( ) bearer = jsonToken [ "token" ] response = requests . head ( requests_url , headers = { 'Authorization' : 'Bearer {}' . format ( bearer ) } ) if not response . ok : raise ApplianceImageNotFound ( origAppliance , requests_url , response . status_code ) else : return origAppliance
Checks docker.io to see if an image exists using the requests library.

    URL is based on the docker v2 schema.  Requires that an access token be fetched first.

    :param str origAppliance: The full url of the docker image originally
                              specified by the user (or the default).  e.g. "ubuntu:latest"
    :param str imageName: The image, including path and excluding the tag. e.g. "ubuntu"
    :param str tag: The tag used at that docker image's registry.  e.g. "latest"
    :return: Return True if match found.  Raise otherwise.