-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.py
40 lines (29 loc) · 1.14 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import logging
import os
import sys
from werkzeug.security import generate_password_hash
log = logging.getLogger("app.config")
## Configuration Setings
# Admin Password. Auth disabled if unset
ADMIN_PASSWORD = os.environ.get("KRONIC_ADMIN_PASSWORD", None)
ADMIN_USERNAME = os.environ.get("KRONIC_ADMIN_USERNAME", "kronic")
# Comma separated list of namespaces to allow access to
ALLOW_NAMESPACES = os.environ.get("KRONIC_ALLOW_NAMESPACES", None)
# Limit to local namespace. Supercedes `ALLOW_NAMESPACES`
NAMESPACE_ONLY = os.environ.get("KRONIC_NAMESPACE_ONLY", False)
# Boolean of whether this is a test environment, disables kubeconfig setup
TEST = os.environ.get("KRONIC_TEST", False)
## Config Logic
USERS = {}
if ADMIN_PASSWORD:
USERS = {ADMIN_USERNAME: generate_password_hash(ADMIN_PASSWORD)}
# Set allowed namespaces to the installed namespace only
if NAMESPACE_ONLY:
try:
KRONIC_NAMESPACE = os.environ["KRONIC_NAMESPACE"]
except KeyError as e:
log.error(
"ERROR: KRONIC_NAMESPACE variable not set and a NAMESPACE_ONLY mode was specified."
)
sys.exit(1)
ALLOW_NAMESPACES = KRONIC_NAMESPACE