mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user