1
0

Use SecretLoader
Some checks failed
Test Python / Test (push) Failing after 29s

This commit is contained in:
Jon Michael Aanes 2024-07-08 00:08:52 +02:00
parent 384f54e970
commit 6903043ab5
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 3 additions and 21 deletions

View File

@ -1,25 +1,6 @@
import logging from secret_loader import SecretLoader
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
load_secret = SecretLoader(env_key_prefix = 'CF_PD').load
# Crunchyroll # Crunchyroll
CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID') CRUNCHYROLL_DEVICE_ID = load_secret('CRUNCHYROLL_DEVICE_ID')

View File

@ -8,3 +8,4 @@ frozendict
python-kucoin python-kucoin
krakenex krakenex
fin-depo @ git+https://gitfub.space/Jmaa/fin-depo.git fin-depo @ git+https://gitfub.space/Jmaa/fin-depo.git
secret_loader @ https://gitfub.space/Jmaa/secret_loader