Ejemplo n.º 1
0
def quay_mirrors(ctx):
    apps = queries.get_quay_repos()

    mirrors = []
    for app in apps:
        quay_repos = app['quayRepos']

        if quay_repos is None:
            continue

        for qr in quay_repos:
            org_name = qr['org']['name']
            for item in qr['items']:
                mirror = item['mirror']

                if mirror is None:
                    continue

                name = item['name']
                url = item['mirror']['url']
                public = item['public']

                mirrors.append({
                    'repo': f'quay.io/{org_name}/{name}',
                    'public': public,
                    'upstream': url,
                })

    columns = ['repo', 'upstream', 'public']
    print_output(ctx.obj['output'], mirrors, columns)
Ejemplo n.º 2
0
    def process_repos_query():
        apps = queries.get_quay_repos()

        summary = defaultdict(list)

        for app in apps:
            quay_repos = app.get('quayRepos')

            if quay_repos is None:
                continue

            for quay_repo in quay_repos:
                org = quay_repo['org']['name']
                instance = quay_repo['org']['instance']['name']
                server_url = quay_repo['org']['instance']['url']

                for item in quay_repo['items']:
                    if item['mirror'] is None:
                        continue

                    mirror_image = Image(item['mirror']['url'])
                    if (mirror_image.registry == 'docker.io'
                            and mirror_image.repository == 'library'
                            and item['public']):
                        _LOG.error("Image %s can't be mirrored to a public "
                                   "quay repository.", mirror_image)
                        sys.exit(ExitCodes.ERROR)

                    org_key = OrgKey(instance, org)
                    summary[org_key].append({'name': item["name"],
                                             'mirror': item['mirror'],
                                             'server_url': server_url})

        return summary
Ejemplo n.º 3
0
    def process_repos_query(cls):
        apps = queries.get_quay_repos()

        summary = defaultdict(list)

        for app in apps:
            quay_repos = app.get("quayRepos")

            if quay_repos is None:
                continue

            for quay_repo in quay_repos:
                org = quay_repo["org"]["name"]
                instance = quay_repo["org"]["instance"]["name"]
                server_url = quay_repo["org"]["instance"]["url"]

                for item in quay_repo["items"]:
                    if item["mirror"] is None:
                        continue

                    mirror_image = Image(item["mirror"]["url"],
                                         response_cache=cls.response_cache)
                    if (mirror_image.registry == "docker.io"
                            and mirror_image.repository == "library"
                            and item["public"]):
                        _LOG.error(
                            "Image %s can't be mirrored to a public "
                            "quay repository.",
                            mirror_image,
                        )
                        sys.exit(ExitCodes.ERROR)

                    org_key = OrgKey(instance, org)
                    summary[org_key].append({
                        "name": item["name"],
                        "mirror": item["mirror"],
                        "server_url": server_url,
                    })

        return summary