Get the tag information using authentication credentials provided by the
    user.

    :param image_name: The image name to query
    :param branch: The branch to filter by
    :return: A list of Version instances, latest first
196930
def get_all_tags_with_auth(image_name, branch=None):
    
    logging.debug('Getting %s with authentication' % image_name)
    url = '%s/%s/images' % (API_URL, image_name)

    registry_user = os.environ.get('REGISTRY_USER')
    registry_pass = os.environ.get('REGISTRY_PASS')

    if registry_user is None or registry_pass is None:
        msg = ('The docker image seems to be private and no authentication'
               ' credentials were provided. Please set REGISTRY_USER and'
               ' REGISTRY_PASS environment variables and try again.')
        raise DockerTagNamingException(msg)

    user_credentials = (registry_user, registry_pass)

    headers = {'X-Docker-Token': 'true',
               'Accept': 'application/json',
               'Content-Type': 'application/json'}

    try:
        response = requests.get(url, auth=user_credentials, headers=headers)
    except RequestException, re:
        raise DockerTagNamingException('HTTP request exception "%s"' % re)

    if response.status_code in (404, 401):
        msg = ('Received unexpected status code %s from the registry'
               ' REST API after sending authentication credentials, the image'
               ' might not exist or is private.')
        raise AuthException(msg % response.status_code)

    token = response.headers.get('x-docker-token')
    endpoint = response.headers.get('x-docker-endpoints')

    if token is None:
        raise DockerTagNamingException('No token returned by the REST API')

    if endpoint is None:
        raise DockerTagNamingException('No docker endpoint returned by the'
                                       ' REST API')

    url = 'https://{0}/v1/repositories/{1}/tags'.format(endpoint, image_name)
    headers['Authorization'] = 'Token %s' % token
    try:
        response = requests.get(url, headers=headers)
    except RequestException, re:
        raise DockerTagNamingException('HTTP request exception "%s"' % re)

    if response.status_code in (404,):
        logging.debug('Received unexpected status code %s from the registry'
                      ' REST API, the image might not exist in the registry'
                      ' but was registered in the hub.')
        return []

    if response.status_code != 200:
        msg = ('Received unexpected status code %s from the registry'
               ' REST API. Please report a bug.')
        raise AuthException(msg % response.status_code)

    try:
        json_data = response.json()
    except ValueError:
        msg = 'JSON decode failed! Raw data is: "%s". Please report a bug.'
        raise DockerTagNamingException(msg % (response.content[:25]).strip())

    #
    #   Note that the registry returns a different format
    #
    output = []

    for tag_name in json_data.keys():
        try:
            version = version_parser(tag_name)
        except Exception, e:
            msg = 'Ignoring version tag "%s" with incorrect format: "%s"'
            logging.debug(msg % (tag_name, e))
            continue

        if branch is not None:
            if version.branch != branch:
                continue

        output.append(version)

    def sort_func(version_a, version_b):
        return cmp(version_b.version_number, version_a.version_number)

    output.sort(sort_func)

    return output
1232445
def framework_version_from_tag(image_tag):
    
    tag_pattern = re.compile('^(.*)-(cpu|gpu)-(py2|py3)$')
    tag_match = tag_pattern.match(image_tag)
    return None if tag_match is None else tag_match.group(1)
726185
def _get_image_url(self, image_id):
        
        gce = self._connect()
        filter = "name eq %s" % image_id
        request = gce.images().list(project=self._project_id, filter=filter)
        response = self._execute_request(request)
        response = self._wait_until_done(response)

        image_url = None
        if "items" in response:
            image_url = response["items"][0]["selfLink"]

        if image_url:
            return image_url
        else:
            raise ImageError("Could not find given image id `%s`" % image_id)
48873
def image_authn(self):
        
        authn_cookie = request.cookies.get(
            self.access_cookie_name, default='[none]')
        return self.access_cookie_valid(authn_cookie, "image_authn: auth cookie")
148002
def image_id_from_registry(image_name):
    """"""
    registry, repository, tag = parse(image_name)
    try:
        token = auth_token(registry, repository).get("token")
        # dockerhub is crazy
        if registry == "index.docker.io":
            registry = "registry-1.docker.io"
        res = requests.head("https://{}/v2/{}/manifests/{}".format(registry, repository, tag), headers={
            "Authorization": "Bearer {}".format(token),
            "Accept": "application/vnd.docker.distribution.manifest.v2+json"
        }, timeout=5)
        res.raise_for_status()
    except requests.RequestException:
        log.error("Received {} when attempting to get digest for {}".format(
            res, image_name))
        return None
    return "@".join([registry+"/"+repository, res.headers["Docker-Content-Digest"]])
161294
async def async_get_image_names(self):
        

        cookies = self.get_session_cookie()
        try:
            async with aiohttp.ClientSession(cookies=cookies) as session:
                resp = await session.get(
                    self._base_url
                )
                t = await resp.text()
                match = re.findall('(?:\w|\d|")/(.*?).(?:mjpg|jpg)', t)
                if len(match) == 0:
                    raise XeomaError('Unable to find any camera image names')
                image_names = set(match)
                results = []
                for image_name in image_names:
                    match = re.search(
                        image_name + '\.(?:mjpg|jpg).*?user=(.*?)&', t
                    )
                    if match and len(match.group(1)) > 0:
                        d = base64.b64decode(unquote(match.group(1))) \
                            .decode('ASCII')
                        creds = d.split(':')
                        if len(creds) < 2:
                            raise XeomaError('Error parsing image credentials')
                        results.append((image_name, creds[0], creds[1]))
                    else:
                        results.append((image_name, None, None))
                return results
        except asyncio.TimeoutError as e:
            raise XeomaError("Unable to connect to Xeoma web server")
410565
def fetch_image(client, name):
    
    try:
        image = client.images.get(name)
    except docker.errors.ImageNotFound:
        name, tag = _parse_image_tag(name)
        tag = 'latest' if tag is None else tag

        log.info("Pulling tag '{}' for image '{}'...".format(tag, name))
        image = client.images.pull(name, tag=tag)

    log.debug("Found image '{}' for tag '{}'".format(image.id, name))
    return image
1109617
def _find_image(name):
    '''
    
    '''
    try:
        images = __salt__['glance.image_list'](name=name)
    except kstone_Unauthorized:
        return False, 'keystoneclient: Unauthorized'
    except glance_Unauthorized:
        return False, 'glanceclient: Unauthorized'
    log.debug('Got images: %s', images)

    if type(images) is dict and len(images) == 1 and 'images' in images:
        images = images['images']

    images_list = images.values() if type(images) is dict else images

    if not images_list:
        return None, 'No image with name "{0}"'.format(name)
    elif len(images_list) == 1:
        return images_list[0], 'Found image {0}'.format(name)
    elif len(images_list) > 1:
        return False, 'Found more than one image with given name'
    else:
        raise NotImplementedError
367350
def get_image_tags(self):
        
        current_images = self.images()
        tags = {tag: i['Id'] for i in current_images for tag in i['RepoTags']}
        return tags
939294
def parse_image_name(name):
    
    name = name or ""
    if '/' in name:
        repository, other = name.split('/')
    else:
        repository, other = None, name

    if ':' in other:
        name, version = other.split(':')
    else:
        name, version = other, 'latest'

    return repository, name, version
168694
def url(name = nil)
      if name
        if version_identifiers.include?(name.to_s)
          self[:@versions][name.to_s][:@url]
        else
          raise "Invalid Image Version identifier: '#{name}' (must be #{version_identifiers.join(', ')})"
        end
      else
        self[:@url]
      end
    end
27065
def update_image_digest(self, image, platform, digest):
        
        image_name_tag = self._key(image)

        image_name = image.to_str(tag=False)
        name_digest = '{}@{}'.format(image_name, digest)

        image_digests = self._images_digests.setdefault(image_name_tag, {})
        image_digests[platform] = name_digest
534323
def get_image_code(self, id_code, access_token=None, user_id=None):
        
        if access_token:
            self.req.credential.set_token(access_token)
        if user_id:
            self.req.credential.set_user_id(user_id)
        if not self.check_credentials():
            raise CredentialsError('credentials invalid')
        return self.req.get('/Codes/' + id_code + '/export/png/url')
1353092
def get_branch_container_tag(self):
        
        if self.__prefix:
            return "{0}-{1}".format(
                self.__prefix,
                self.__branch)
        else:
            return "{0}".format(self.__branch)
1278209
def list_branch(self, repo_name):
        
        req = proto.ListBranchRequest(repo=proto.Repo(name=repo_name))
        res = self.stub.ListBranch(req, metadata=self.metadata)
        if hasattr(res, 'branch_info'):
            return res.branch_info
        return []
6935
def image_list(self, name=None):
        '''
        
        '''
        nt_ks = self.compute_conn
        ret = {}
        for image in nt_ks.images.list():
            links = {}
            for link in image.links:
                links[link['rel']] = link['href']
            ret[image.name] = {
                'name': image.name,
                'id': image.id,
                'status': image.status,
                'progress': image.progress,
                'created': image.created,
                'updated': image.updated,
                'metadata': image.metadata,
                'links': links,
            }
            if hasattr(image, 'minDisk'):
                ret[image.name]['minDisk'] = image.minDisk
            if hasattr(image, 'minRam'):
                ret[image.name]['minRam'] = image.minRam
        if name:
            return {name: ret[name]}
        return ret
1371079
def image_exists(self, id=None, tag=None):
        
        exists = False
        if id and self.image_by_id(id):
            exists = True
        elif tag and self.image_by_tag(tag):
            exists = True

        return exists