|
3 | 3 | import json |
4 | 4 | import logging |
5 | 5 | import re |
6 | | -import urllib.request |
7 | 6 | from typing import cast, Dict |
8 | 7 | from urllib.parse import quote |
9 | 8 |
|
|
12 | 11 | import yaml |
13 | 12 |
|
14 | 13 | import artbotlib.exectools |
15 | | - |
| 14 | +from artbotlib import constants |
16 | 15 | from . import util |
17 | | -from .constants import RHCOS_BASE_URL |
18 | 16 | from .rhcos import RHCOSBuildInfo |
19 | 17 |
|
20 | 18 | logger = logging.getLogger(__name__) |
@@ -120,17 +118,38 @@ async def get_tag_specs(so, tag_spec, data_type, sem) -> str: |
120 | 118 | distgit_name = component_name.rstrip('container') |
121 | 119 | distgit_name = distgit_name.rstrip("-") |
122 | 120 |
|
123 | | - result += f'https://pkgs.devel.redhat.com/cgit/containers/{distgit_name}/commit/?id={component_distgit_commit}' |
| 121 | + result += f'{constants.DISTGIT_URL}/{distgit_name}/commit/?id={component_distgit_commit}' |
| 122 | + |
124 | 123 | elif data_type.startswith('commit'): |
125 | 124 | result += f'{component_upstream_commit_url}' |
126 | 125 | elif data_type.startswith('catalog'): |
127 | | - result += f'{component_rhcc_url}' |
| 126 | + image_type = 'distgit' |
| 127 | + suffix = "-container" |
| 128 | + catalog_name = "" |
| 129 | + if suffix in component_name: |
| 130 | + catalog_name = component_name.rstrip('container') |
| 131 | + catalog_name = catalog_name.rstrip("-") |
| 132 | + |
| 133 | + version = component_version.strip('v') |
| 134 | + version = version[:4] |
| 135 | + data_info = catalog_api_query(so, image_type, catalog_name, version) |
| 136 | + |
| 137 | + result += f"{constants.CATALOG_URL}/{data_info[0]}/{data_info[1]}" |
128 | 138 | elif data_type.startswith('image'): |
129 | 139 | result += release_component_image |
130 | 140 |
|
131 | 141 | logger.debug('Tag specs for %s: %s', data_type, result) |
132 | 142 | return result |
133 | 143 |
|
| 144 | +def catalog_api_query(so,image_type,catalog_name,version): |
| 145 | + url = f"{constants.ART_DASH_API_ROUTE}/" \ |
| 146 | + f"pipeline-image?starting_from={image_type}&name={catalog_name}&version={version}" |
| 147 | + response = requests.get(url) |
| 148 | + catalogs_info = response.json() |
| 149 | + catalog_id = catalogs_info['payload']['distgit'][0]['brew']['cdn'][0]['delivery']['delivery_repo_id'] |
| 150 | + catalog_repo = catalogs_info['payload']['distgit'][0]['brew']['cdn'][0]['delivery']['delivery_repo_name'] |
| 151 | + catalog_data = (catalog_repo, catalog_id) |
| 152 | + return catalog_data |
134 | 153 |
|
135 | 154 | def list_component_data_for_release_tag(so, data_type, release_tag): |
136 | 155 | data_type = data_type.lower() |
@@ -159,7 +178,8 @@ def list_component_data_for_release_tag(so, data_type, release_tag): |
159 | 178 | payload = f'Finding information for: {image_url}\n' |
160 | 179 |
|
161 | 180 | release_info = json.loads(stdout) |
162 | | - tag_specs = list(release_info['references']['spec']['tags']) |
| 181 | + tag_specs = list(release_info['references']['spec']['tags'][:10]) |
| 182 | + #tag_specs = list(release_info['references']['spec']['tags']) |
163 | 183 |
|
164 | 184 | loop = asyncio.new_event_loop() |
165 | 185 | asyncio.set_event_loop(loop) |
|
0 commit comments