Skip to content

Commit 26bc6b4

Browse files
committed
ART-8680: fixed art-bot query using catalogs
1 parent 4410d00 commit 26bc6b4

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

artbotlib/brew_list.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
import logging
55
import re
6-
import urllib.request
76
from typing import cast, Dict
87
from urllib.parse import quote
98

@@ -12,9 +11,8 @@
1211
import yaml
1312

1413
import artbotlib.exectools
15-
14+
from artbotlib import constants
1615
from . import util
17-
from .constants import RHCOS_BASE_URL
1816
from .rhcos import RHCOSBuildInfo
1917

2018
logger = logging.getLogger(__name__)
@@ -120,17 +118,38 @@ async def get_tag_specs(so, tag_spec, data_type, sem) -> str:
120118
distgit_name = component_name.rstrip('container')
121119
distgit_name = distgit_name.rstrip("-")
122120

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+
124123
elif data_type.startswith('commit'):
125124
result += f'{component_upstream_commit_url}'
126125
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]}"
128138
elif data_type.startswith('image'):
129139
result += release_component_image
130140

131141
logger.debug('Tag specs for %s: %s', data_type, result)
132142
return result
133143

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
134153

135154
def list_component_data_for_release_tag(so, data_type, release_tag):
136155
data_type = data_type.lower()
@@ -159,7 +178,8 @@ def list_component_data_for_release_tag(so, data_type, release_tag):
159178
payload = f'Finding information for: {image_url}\n'
160179

161180
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'])
163183

164184
loop = asyncio.new_event_loop()
165185
asyncio.set_event_loop(loop)

artbotlib/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919

2020
BREW_URL = 'https://brewweb.engineering.redhat.com/brew'
2121

22+
CATALOG_URL = 'https://catalog.redhat.com/software/containers'
23+
2224
CGIT_URL = 'https://pkgs.devel.redhat.com/cgit'
2325

2426
COMET_URL = 'https://comet.engineering.redhat.com/containers/repositories'
2527

28+
DISTGIT_URL = 'https://pkgs.devel.redhat.com/cgit/containers'
29+
2630
ERRATA_TOOL_URL = 'https://errata.devel.redhat.com'
2731

2832
GITHUB_API_REPO_URL = "https://api.github.com/repos"

0 commit comments

Comments
 (0)