Show history of all known repo/tags for image
971316
def show_taghistory():
    """"""


    if not nav:
        sys.exit(1)

    ecode = 0
    try:
        result = nav.get_taghistory()
        if result:
            anchore_utils.print_result(config, result)

    except:
        anchore_print_err("operation failed")
        ecode = 1

    contexts['anchore_allimages'].clear()
    sys.exit(ecode)
1192169
def track(context, file_names):
    
    context.obj.find_repo_type()
    for fn in file_names:
        context.obj.call([context.obj.vc_name, 'add', fn])
850072
def get_experiment_image_info(experiment: 'Experiment') -> Tuple[str, str]:
    """"""
    project_name = experiment.project.name
    repo_name = project_name

    image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
    image_tag = experiment.code_reference.commit
    return image_name, image_tag
1156170
def parse(cls, image_name):
        
        result = cls()

        # registry.org/namespace/repo:tag
        s = image_name.split('/', 2)

        if len(s) == 2:
            if '.' in s[0] or ':' in s[0]:
                result.registry = s[0]
            else:
                result.namespace = s[0]
        elif len(s) == 3:
            result.registry = s[0]
            result.namespace = s[1]
        result.repository = s[-1]

        try:
            result.repository, result.digest = result.repository.rsplit("@", 1)
        except ValueError:
            try:
                result.repository, result.tag = result.repository.rsplit(":", 1)
            except ValueError:
                result.tag = "latest"

        return result
677136
def tag(self, sbo):
        
        # split sbo name with version and get name
        sbo_name = "-".join(sbo.split("-")[:-1])
        find = GetFromInstalled(sbo_name).name()
        if find_package(sbo, self.meta.pkg_path):
            paint = self.meta.color["GREEN"]
            self.count_ins += 1
            if "--rebuild" in self.flag:
                self.count_upg += 1
        elif sbo_name == find:
            paint = self.meta.color["YELLOW"]
            self.count_upg += 1
        else:
            paint = self.meta.color["RED"]
            self.count_uni += 1
        return paint
1347780
def repository(name):
    """"""
    user_id = current_user.id
    github = GitHubAPI(user_id=user_id)
    token = github.session_token

    if token:
        repos = github.account.extra_data.get('repos', [])
        repo = next((repo for repo_id, repo in repos.items()
                     if repo.get('full_name') == name), {})
        if not repo:
            abort(403)

        try:
            # NOTE: Here we do not check for repository ownership, since it
            # might have changed even though the user might have made releases
            # in the past.
            repo_instance = Repository.get(user_id=user_id,
                                           github_id=repo['id'],
                                           check_owner=False)
        except RepositoryAccessError:
            abort(403)
        except NoResultFound:
            repo_instance = Repository(name=repo['full_name'],
                                       github_id=repo['id'])

        releases = [
            current_github.release_api_class(r) for r in (
                repo_instance.releases.order_by(db.desc(Release.created)).all()
                if repo_instance.id else []
            )
        ]
        return render_template(
            current_app.config['GITHUB_TEMPLATE_VIEW'],
            repo=repo_instance,
            releases=releases,
            serializer=current_github.record_serializer,
        )

    abort(403)
1090831
def list_images(self, repository_name, registry_id=None):
        
        repository = None
        found = False
        if repository_name in self.repositories:
            repository = self.repositories[repository_name]
            if registry_id:
                if repository.registry_id == registry_id:
                    found = True
            else:
                found = True

        if not found:
            raise RepositoryNotFoundException(repository_name, registry_id or DEFAULT_REGISTRY_ID)

        images = []
        for image in repository.images:
            images.append(image)
        return images
1208281
def _missing_imageinfo(self):
        
        if 'image' not in self.data:
            return
        missing = []
        for img in self.data['image']:
            if 'url' not in img:
                missing.append(img['file'])
        return list(set(missing))
432123
def _list_repos():
    
    if not args["list"]:
        return
    
    #Just loop over the list of repos we have in a server instance. See if
    #they also exist in the db's status; if they do, include the start/end
    #times we have saved.
    from pyci.server import Server
    server = Server(testmode=args["nolive"])
    output = ["Repository           |      Started     |      Finished    | XML File Path",
              "--------------------------------------------------------------------------"]

    dbs = {} if "status" not in db else db["status"]
    fullfmt = "{0:<20} | {1:^16} | {2:^16} | {3}"
    for reponame, repo in server.repositories.items():
        if reponame in dbs:
            start = _fmt_time(dbs[reponame]["start"])
            end = _fmt_time(dbs[reponame]["end"])
        else:
            start = "Never"
            end = "Never"
        output.append(fullfmt.format(reponame, start, end, repo.filepath))

    info('\n'.join(output))
1051581
def find_tags(self):
        """"""
        listing = self.context.capture('hg', 'tags')
        for line in listing.splitlines():
            tokens = line.split()
            if len(tokens) >= 2 and ':' in tokens[1]:
                revision_number, revision_id = tokens[1].split(':')
                yield Revision(
                    repository=self,
                    revision_id=revision_id,
                    revision_number=int(revision_number),
                    tag=tokens[0],
                )
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"]])
305604
def find_tags(self):
        """"""
        listing = self.context.capture('git', 'show-ref', '--tags', check=False)
        for line in listing.splitlines():
            tokens = line.split()
            if len(tokens) >= 2 and tokens[1].startswith('refs/tags/'):
                yield Revision(
                    repository=self,
                    revision_id=tokens[0],
                    tag=tokens[1][len('refs/tags/'):],
                )
124203
async def tag(self, name: str, repo: str, *, tag: str = None) -> bool:
        
        params = {"repo": repo}

        if tag:
            params["tag"] = tag

        await self.docker._query(
            "images/{name}/tag".format(name=name),
            "POST",
            params=params,
            headers={"content-type": "application/json"},
        )
        return True
299081
def get_tags(ctx, archive_name):
    '''
    
    '''

    _generate_api(ctx)

    var = ctx.obj.api.get_archive(archive_name)

    click.echo(' '.join(var.get_tags()), nl=False)
    print('')
447152
def image_exists(self, image_name, tag='latest'):
        
        code, image = self.image_tags(image_name)
        if code != httplib.OK:
            return False
        tag = tag.lower()
        return any(x.lower() == tag for x in image.tags)
880016
def tag(self, repository_tag, tags=[]):
        
        if not isinstance(repository_tag, six.string_types):
            raise TypeError('repository_tag must be a string')

        if not isinstance(tags, list):
            raise TypeError('tags must be a list.')

        if ':' in repository_tag:
            repository, tag = repository_tag.split(':')
            tags.append(tag)
        else:
            repository = repository_tag

            if not tags:
                tags.append('latest')

        for tag in tags:
            repo_tag = "{0}:{1}".format(repository, tag)

            if repo_tag not in self.repo_tags:
                logger.info("Tagging Image: {0} Repo Tag: {1}".format(self.identifier, repo_tag))
                self.repo_tags = self.repo_tags + (repo_tag, )

                # always going to force tags until a feature is added to allow users to specify.
                try:
                    self.client.tag(self.id, repository, tag)
                except:
                    self.client.tag(self.id, repository, tag, force=True)
1322973
def history(namespace_module):
    """"""
    for path in get_namespace_history(namespace_module):
        h = get_bel_resource_hash(path.as_posix())
        click.echo('{}\t{}'.format(path, h))