Dynamically set authenticator properties from YAML

We don't wanna explicitly map keys from the YAML to traitlet
config for the authentication - that's a lot of busywork for no
gain. We instead switch to using snake_case everywhere, and
dynamically set traitlet config from YAML config!
This commit is contained in:
yuvipanda
2018-07-15 13:40:17 -07:00
parent ba7545769f
commit 9bf4a64826
2 changed files with 37 additions and 23 deletions

View File

@@ -4,6 +4,8 @@ JupyterHub config for the littlest jupyterhub.
import os
from systemdspawner import SystemdSpawner
from tljh import user, configurer
import yaml
import copy
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
@@ -40,4 +42,10 @@ c.SystemdSpawner.default_shell = '/bin/bash'
# Drop the '-singleuser' suffix present in the default template
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}'
configurer.apply_yaml_config(os.path.join(INSTALL_PREFIX, 'config.yaml'), c)
config_overrides_path = os.path.join(INSTALL_PREFIX, 'config.yaml')
if os.path.exists(config_overrides_path):
with open(config_overrides_path) as f:
config_overrides = yaml.safe_load(f)
else:
config_overrides = {}
configurer.apply_config(config_overrides, c)