Skip to content

Commit

Permalink
fixed art-bot query using catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbiarnes committed Feb 20, 2024
1 parent 4410d00 commit 408dfdb
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions artbotlib/brew_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import logging
import re
import urllib.request
from typing import cast, Dict
from urllib.parse import quote

Expand All @@ -12,9 +11,8 @@
import yaml

import artbotlib.exectools

from artbotlib import constants
from . import util
from .constants import RHCOS_BASE_URL
from .rhcos import RHCOSBuildInfo

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -124,13 +122,38 @@ async def get_tag_specs(so, tag_spec, data_type, sem) -> str:
elif data_type.startswith('commit'):
result += f'{component_upstream_commit_url}'
elif data_type.startswith('catalog'):
result += f'{component_rhcc_url}'
image_type = 'distgit'
suffix = "-container"
catalog_name = ""
if suffix in component_name:
catalog_name = component_name.rstrip('container')
catalog_name = catalog_name.rstrip("-")

version = component_version.strip('v')
version = version[:4]
data_info = catalog_api_query(so, image_type, catalog_name, version)
logger.info(f"RECEIVED CATALOG_DATA: {data_info}")

result += f'https://catalog.redhat.com/software/containers/{data_info[0]}/{data_info[1]}'
elif data_type.startswith('image'):
result += release_component_image

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

def catalog_api_query(so,image_type,catalog_name,version):
url = f"{constants.ART_DASH_API_ROUTE}/" \
f"pipeline-image?starting_from={image_type}&name={catalog_name}&version={version}"
logger.info(f"the URL to query is: {url}")
response = requests.get(url)
catalogs_info = response.json()
logger.info(f"JSON_DATA: {catalogs_info}")
catalog_id = catalogs_info['payload']['distgit'][0]['brew']['cdn'][0]['delivery']['delivery_repo_id']
catalog_repo = catalogs_info['payload']['distgit'][0]['brew']['cdn'][0]['delivery']['delivery_repo_name']
logger.info(f"CATALOG_ID: {catalog_id}")
logger.info(f"CATALOG_REPO: {catalog_repo}")
catalog_data = (catalog_repo, catalog_id)
return catalog_data

def list_component_data_for_release_tag(so, data_type, release_tag):
data_type = data_type.lower()
Expand Down Expand Up @@ -159,7 +182,7 @@ def list_component_data_for_release_tag(so, data_type, release_tag):
payload = f'Finding information for: {image_url}\n'

release_info = json.loads(stdout)
tag_specs = list(release_info['references']['spec']['tags'])
tag_specs = list(release_info['references']['spec']['tags'][:3])

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
Expand Down

0 comments on commit 408dfdb

Please sign in to comment.