Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: rename env var for logging + cred handling #387

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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