From 6903043ab5736762347e72d588f8bc58cf30cb2c Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 8 Jul 2024 00:08:52 +0200 Subject: [PATCH] Use SecretLoader --- personal_data/secrets.py | 23 ++--------------------- requirements.txt | 1 + 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/personal_data/secrets.py b/personal_data/secrets.py index 7984c1e..19967ff 100644 --- a/personal_data/secrets.py +++ b/personal_data/secrets.py @@ -1,25 +1,6 @@ -import logging -import os - -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - -ENV_KEY_PREFIX = 'CF_PD_' - - -def load_secret(env_key: str) -> str: - filepath = os.environ.get(ENV_KEY_PREFIX + env_key) - if filepath is None: - filepath = f'./secrets/{env_key.lower()}' - try: - with open(filepath) as f: - value = f.read().strip() - logger.info('Loaded secret: %s', env_key) - return value - except Exception: - logger.exception('Could not load secret %s', env_key) - return None +from secret_loader import SecretLoader +load_secret = SecretLoader(env_key_prefix = 'CF_PD').load # Crunchyroll CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID') diff --git a/requirements.txt b/requirements.txt index 0b17b31..ea77961 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ frozendict python-kucoin krakenex fin-depo @ git+https://gitfub.space/Jmaa/fin-depo.git +secret_loader @ https://gitfub.space/Jmaa/secret_loader