Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Change community corgi env var URL from API to server
Browse files Browse the repository at this point in the history
Leftover from OSIDB/CORGI API to SERVER change
  • Loading branch information
JakubFrejlach committed Nov 28, 2023
1 parent 84baa9f commit 6c02bd6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export CORGI_SERVER_URL="https://<INSERT COMPONENT REGISTRY API URL>"

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.
Expand Down
22 changes: 17 additions & 5 deletions griffon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions griffon/commands/entities/community_component_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)

from griffon import (
COMMUNITY_COMPONENTS_API_URL,
COMMUNITY_COMPONENTS_SERVER_URL,
CORGI_SERVER_URL,
CommunityComponentService,
progress_bar,
Expand Down Expand Up @@ -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."""
Expand Down
6 changes: 3 additions & 3 deletions griffon/services/core_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -932,7 +932,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,
Expand Down Expand Up @@ -1021,7 +1021,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,
Expand Down

0 comments on commit 6c02bd6

Please sign in to comment.