From f77c0c25196d4c13505548cb1d6c39db35e12db7 Mon Sep 17 00:00:00 2001 From: Jakub Frejlach Date: Thu, 23 Nov 2023 16:06:45 +0100 Subject: [PATCH] Change community corgi env var URL from API to server Leftover from OSIDB/CORGI API to SERVER change --- docs/user_guide.md | 2 +- griffon/__init__.py | 22 ++++++++++++++----- .../entities/community_component_registry.py | 4 ++-- griffon/services/core_queries.py | 6 ++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/user_guide.md b/docs/user_guide.md index 96c9f55..6d3d25e 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -67,7 +67,7 @@ export CORGI_SERVER_URL="https://" and the following is set to enable searching community components: ```commandline -export COMMUNITY_COMPONENTS_API_URL="https://component-registry.fedoraproject.org" +export COMMUNITY_COMPONENTS_SERVER_URL="https://component-registry.fedoraproject.org" ``` Your system must be properly authorised to access all these systems. diff --git a/griffon/__init__.py b/griffon/__init__.py index eb08e9b..c195f01 100644 --- a/griffon/__init__.py +++ b/griffon/__init__.py @@ -29,9 +29,11 @@ OSIDB_PASSWORD = os.getenv("OSIDB_PASSWORD", "") OSIDB_AUTH_METHOD = os.getenv("OSIDB_AUTH_METHOD", "kerberos") +# TODO: Deprecate COMMUNITY_COMPONENTS_API_URL completely in the next version or two # required to enable --search-community -COMMUNITY_COMPONENTS_API_URL = os.getenv( - "COMMUNITY_COMPONENTS_API_URL", "https://component-registry.fedoraproject.org" +COMMUNITY_COMPONENTS_SERVER_URL = os.getenv( + "COMMUNITY_COMPONENTS_SERVER_URL", + os.getenv("COMMUNITY_COMPONENTS_API_URL", "https://component-registry.fedoraproject.org"), ) # TODO: temporary hack required to enable searching of middleware @@ -58,11 +60,21 @@ def check_envvars(): f"switch to the new environment variable.{Style.RESET}" ) ) - if "CORGI_SERVER_URL" not in os.environ and "CORGI_API_URL" not in os.environ: print("Must set CORGI_SERVER_URL environment variable.") exit(1) + # TODO: Deprecate COMMUNITY_COMPONENTS_API_URL completely in the next version or two + if "COMMUNITY_COMPONENTS_API_URL" in os.environ: + print( + ( + f"{Style.BOLD}{Color.YELLOW}WARNING: COMMUNITY_COMPONENTS_API_URL " + "will be deprecated in the next version of Griffon in favour of " + "COMMUNITY_COMPONENTS_SERVER_URL, please switch to the new environment " + f"variable.{Style.RESET}" + ) + ) + # TODO: Deprecate OSIDB_API_URL completely in the next version or two if "OSIDB_API_URL" in os.environ: print( @@ -294,10 +306,10 @@ def create_session(): """init corgi session""" try: return component_registry_bindings.new_session( - component_registry_server_uri=COMMUNITY_COMPONENTS_API_URL, + component_registry_server_uri=COMMUNITY_COMPONENTS_SERVER_URL, ) except: # noqa - console.log(f"{COMMUNITY_COMPONENTS_API_URL} is not accessible.") + console.log(f"{COMMUNITY_COMPONENTS_SERVER_URL } is not accessible.") exit(1) @staticmethod diff --git a/griffon/commands/entities/community_component_registry.py b/griffon/commands/entities/community_component_registry.py index ae6da1a..e60178c 100644 --- a/griffon/commands/entities/community_component_registry.py +++ b/griffon/commands/entities/community_component_registry.py @@ -33,7 +33,7 @@ ) from griffon import ( - COMMUNITY_COMPONENTS_API_URL, + COMMUNITY_COMPONENTS_SERVER_URL, CORGI_SERVER_URL, CommunityComponentService, progress_bar, @@ -65,7 +65,7 @@ def commmunity_components_grp(ctx): # COMPONENTS -@commmunity_components_grp.group(help=f"{COMMUNITY_COMPONENTS_API_URL}/api/v1/components") +@commmunity_components_grp.group(help=f"{COMMUNITY_COMPONENTS_SERVER_URL}/api/v1/components") @click.pass_context def components(ctx): """Corgi Components.""" diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 4b9e27a..665371c 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -12,7 +12,7 @@ from component_registry_bindings.bindings.python_client.models import Component from griffon import ( - COMMUNITY_COMPONENTS_API_URL, + COMMUNITY_COMPONENTS_SERVER_URL, CORGI_SERVER_URL, OSIDB_SERVER_URL, CommunityComponentService, @@ -947,7 +947,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: "link_affect": f"{OSIDB_SERVER_URL}/osidb/api/v1/affects/{affect.uuid}", # noqa "link_cve": f"{OSIDB_SERVER_URL}/osidb/api/v1/flaws/{flaw.cve_id}", # noqa "link_component": f"{CORGI_SERVER_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa - "link_community_component": f"{COMMUNITY_COMPONENTS_API_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa + "link_community_component": f"{COMMUNITY_COMPONENTS_SERVER_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa "flaw_cve_id": flaw.cve_id, "title": flaw.title, "flaw_resolution": flaw.resolution, @@ -1036,7 +1036,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: "link_affect": f"{OSIDB_SERVER_URL}/osidb/api/v1/affects/{affect.uuid}", # noqa "link_cve": f"{OSIDB_SERVER_URL}/osidb/api/v1/flaws/{flaw.cve_id}", # noqa "link_component": f"{CORGI_SERVER_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa - "link_community_component": f"{COMMUNITY_COMPONENTS_API_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa + "link_community_component": f"{COMMUNITY_COMPONENTS_SERVER_URL}/api/v1/components?name={affect.ps_component}&latest_components_by_streams=True", # noqa "flaw_cve_id": flaw.cve_id, "title": flaw.title, "flaw_state": flaw.state,