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

Commit

Permalink
Deprecate *_API_URL envvars
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFrejlach committed Feb 12, 2024
1 parent 256633d commit ef8bdc4
Showing 1 changed file with 10 additions and 42 deletions.
52 changes: 10 additions & 42 deletions griffon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
griffon cli
"""

import configparser
import logging
import os
Expand All @@ -15,25 +16,23 @@
from pkg_resources import resource_filename
from rich.logging import RichHandler

from griffon.helpers import Color, Style
from griffon.output import console

from .exceptions import GriffonException

__version__ = "0.5.5"

# TODO: Deprecate CORGI_API_URL completely in the next version or two
CORGI_SERVER_URL = os.getenv("CORGI_SERVER_URL", os.getenv("CORGI_API_URL"))
# TODO: Deprecate OSIDB_API_URL completely in the next version or two
OSIDB_SERVER_URL = os.getenv("OSIDB_SERVER_URL", os.getenv("OSIDB_API_URL"))
CORGI_SERVER_URL = os.getenv("CORGI_SERVER_URL")
OSIDB_SERVER_URL = os.getenv("OSIDB_SERVER_URL")

OSIDB_USERNAME = os.getenv("OSIDB_USERNAME", "")
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_SERVER_URL = os.getenv(
"COMMUNITY_COMPONENTS_SERVER_URL",
os.getenv("COMMUNITY_COMPONENTS_API_URL", "https://component-registry.fedoraproject.org"),
"https://component-registry.fedoraproject.org",
)

# TODO: temporary hack required to enable searching of middleware
Expand All @@ -52,42 +51,11 @@
def check_envvars():
"""Check that all necessary envvars are set"""

# TODO: Deprecate CORGI_API_URL completely in the next version or two
if "CORGI_API_URL" in os.environ:
print(
(
f"{Style.BOLD}{Color.YELLOW}WARNING: CORGI_API_URL will be deprecated "
"in the next version of Griffon in favour of CORGI_SERVER_URL, please "
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}"
)
)
mandatory_envvars = ("CORGI_SERVER_URL", "OSIDB_SERVER_URL")

# TODO: Deprecate OSIDB_API_URL completely in the next version or two
if "OSIDB_API_URL" in os.environ:
print(
(
f"{Style.BOLD}{Color.YELLOW}WARNING: OSIDB_API_URL will be deprecated "
"in the next version of Griffon in favour of OSIDB_SERVER_URL, please "
f"switch to the new environment variable.{Style.RESET}"
)
)
if "OSIDB_SERVER_URL" not in os.environ and "OSIDB_API_URL" not in os.environ:
print("Must set OSIDB_SERVER_URL environment variable.")
exit(1)
for envvar in mandatory_envvars:
if envvar not in os.environ:
raise GriffonException(f"Must set {envvar} environment variable.")


def config_logging(level="INFO"):
Expand Down

0 comments on commit ef8bdc4

Please sign in to comment.