Skip to content

Commit

Permalink
feat!: rename env var for logging + cred handling (#387)
Browse files Browse the repository at this point in the history
close #363

* Rename `METAKB_NORM_EB_PROD` to `METAKB_EB_PROD`
  • Loading branch information
korikuzma authored Jul 16, 2024
1 parent d5107ad commit 3b511d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/metakb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _get_credentials(
:return: tuple containing host, and a second tuple containing username/password
"""
if not (uri and credentials[0] and credentials[1]):
if "METAKB_NORM_EB_PROD" in environ:
if "METAKB_EB_PROD" in environ:
secret = ast.literal_eval(_get_secret())
uri = f"bolt://{secret['host']}:{secret['port']}"
credentials = (secret["username"], secret["password"])
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_driver(
Connection URI/credentials are resolved as follows:
1. Use function args if given
2. Use values from AWS secrets manager if env var ``METAKB_NORM_EB_PROD`` is set
2. Use values from AWS secrets manager if env var ``METAKB_EB_PROD`` is set
3. Use values from env vars ``METAKB_DB_URL``, ``METAKB_DB_USERNAME``, and
``METAKB_DB_PASSWORD``, if all are defined
4. Use local defaults: ``"bolt://localhost:7687"``, with username ``"neo4j"``
Expand Down
4 changes: 2 additions & 2 deletions src/metakb/log_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def configure_logs(log_level: int = logging.DEBUG, quiet_upstream: bool = True)
if quiet_upstream:
_quiet_upstream_libs()
log_filename = (
"/tmp/metakb.log" if "METAKB_NORM_EB_PROD" in os.environ else "metakb.log" # noqa: S108
"/tmp/metakb.log" if "METAKB_EB_PROD" in os.environ else "metakb.log" # noqa: S108
)
logging.basicConfig(
filename=log_filename,
Expand All @@ -45,7 +45,7 @@ def configure_logs(log_level: int = logging.DEBUG, quiet_upstream: bool = True)
logger = logging.getLogger("metakb")
logger.setLevel(log_level)

if "METAKB_NORM_EB_PROD" in os.environ:
if "METAKB_EB_PROD" in os.environ:
# force debug logging in production server
logger.handlers = []
handler = logging.StreamHandler()
Expand Down

0 comments on commit 3b511d3

Please sign in to comment.