From 70bbe3361e87e4753dac68d46eee7ca89d9b81a6 Mon Sep 17 00:00:00 2001 From: Paolo Invernizzi Date: Tue, 15 Oct 2024 14:23:38 +0200 Subject: [PATCH] Check API key and add comments --- jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py | 2 ++ .../scripts/bsc_list_generator/bugzilla_client.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py b/jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py index d6079cb80..46c895fd3 100644 --- a/jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py +++ b/jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py @@ -43,6 +43,7 @@ def parse_cli_args() -> argparse.Namespace: def get_bugzilla_product(product_version: str, cloud: bool) -> str: return f"SUSE Manager {product_version}{' in Public Clouds' if cloud else ''}" +# return a txt file formatted according to .md syntax, so that it can be used in GitHub cards and the likes def bugs_to_links_list(products_bugs: dict[str, list[dict]], bugzilla_url: str) -> list[str]: lines: list[str] = [] @@ -78,6 +79,7 @@ def main(): if args.all: for version in _PRODUCT_VERSIONS: + # get both "standard" and cloud product versions bugzilla_products.append(get_bugzilla_product(version, False)) bugzilla_products.append(get_bugzilla_product(version, True)) else: diff --git a/jenkins_pipelines/scripts/bsc_list_generator/bugzilla_client.py b/jenkins_pipelines/scripts/bsc_list_generator/bugzilla_client.py index 3885347fe..fc59301ea 100644 --- a/jenkins_pipelines/scripts/bsc_list_generator/bugzilla_client.py +++ b/jenkins_pipelines/scripts/bsc_list_generator/bugzilla_client.py @@ -5,7 +5,10 @@ class BugzillaClient: + # api_key is needed for actual API calls def __init__(self, api_key: str, base_url: str = _SUSE_BUGZILLA_BASE_URL, api_type: str = "rest"): + if not api_key: + raise ValueError("api_key is None or empty") # private self._api_key: str = api_key self._base_url: str = base_url @@ -16,6 +19,7 @@ def __init__(self, api_key: str, base_url: str = _SUSE_BUGZILLA_BASE_URL, api_ty self.show_bug_url: str = f"{base_url}/show_bug.cgi" def get_bugs(self, **kwargs) -> list[dict[str, Any]]: + # drops CLI args that have not beend used and have no default additional_params: dict[str, Any] = { k: v for k, v in kwargs.items() if v is not None } response: requests.Response = requests.get(self._bugs_endpoint, params={**self._params, **additional_params}) if not response.ok: