Files
job_orchestrator_service/job_orchestrator_service/config.py
2021-04-19 01:34:33 +02:00

44 lines
1.2 KiB
Python

#!/usr/bin/env python3
import os
"""
Configuration
"""
def get_namespace():
namespace = os.environ.get("WORKING_NAMESPACE")
if namespace:
return namespace
# Try to figure out
try:
# https://github.com/kubernetes-client/python/issues/363
with open("/run/secrets/kubernetes.io/serviceaccount/namespace", "r") as f:
namespace = f.read()
except FileNotFoundError:
pass
if namespace:
return namespace
else:
raise Exception("WORKING_NAMESPACE is not configured!")
class Config:
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite://")
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(12))
SENTRY_DSN = os.environ.get("SENTRY_DSN")
RELEASE_ID = os.environ.get("RELEASE_ID", "test")
RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
# Technically this could differ from the one this pod is running in, but no one tests this.
WORKING_NAMESPACE = get_namespace()
AUTO_CLEANUP = bool(os.environ.get("AUTO_CLEANUP", "").upper() in ['YES', 'TRUE', '1'])
URSIM_CONTROL_IMAGE = os.environ["URSIM_CONTROL_IMAGE"]
URSIM_CONTROL_CONFIGMAP = os.environ["URSIM_CONTROL_CONFIGMAP"]