Skip to content

Commit ef20cbb

Browse files
committed
Refactor cwh_repo2docker_jupyterhub_config parameters
1 parent 4f64f97 commit ef20cbb

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

jupyterhub/cwh-repo2docker/cwh_repo2docker/__init__.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def cwh_repo2docker_jupyterhub_config(
172172
config_file=None,
173173
service_name='environments',
174174
custom_menu=False,
175+
service_environments={},
175176
debug=False):
176177
# hub
177178
c.JupyterHub.spawner_class = Repo2DockerSpawner
@@ -199,18 +200,6 @@ def cwh_repo2docker_jupyterhub_config(
199200
"--debug"
200201
])
201202

202-
environ_names = [
203-
'CONTAINER_IMAGE',
204-
'REGISTRY_HOST',
205-
'REGISTRY_USER',
206-
'REGISTRY_PASSWORD'
207-
]
208-
209-
environments = {}
210-
for name in environ_names:
211-
if name in os.environ:
212-
environments[name] = os.environ[name]
213-
214203
c.JupyterHub.template_vars.update({
215204
'cwh_repo2docker_service_name': service_name
216205
})
@@ -221,6 +210,6 @@ def cwh_repo2docker_jupyterhub_config(
221210
"url": "http://127.0.0.1:10101",
222211
"display": not custom_menu,
223212
"oauth_no_confirm": True,
224-
"environment": environments,
213+
"environment": service_environments,
225214
"oauth_client_allowed_scopes": ["inherit"]
226215
}])

jupyterhub/jupyterhub_config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,24 @@ def resources(config):
181181
debug_log = os.environ.get('DEBUG', '0') in ['yes', '1']
182182

183183
## Configure cwh_repo2docker spawner and service
184+
cwh_repo2docker_environ_names = [
185+
'CONTAINER_IMAGE',
186+
'REGISTRY_HOST',
187+
'REGISTRY_USER',
188+
'REGISTRY_PASSWORD'
189+
]
190+
191+
service_environments = {}
192+
for name in cwh_repo2docker_environ_names:
193+
if name in os.environ:
194+
service_environments[name] = os.environ[name]
195+
184196
cwh_repo2docker_config_path = '/srv/jupyterhub/cwh_repo2docker_config.py'
185197
cwh_repo2docker_jupyterhub_config(
186198
c,
187199
config_file=cwh_repo2docker_config_path,
188200
custom_menu=True,
201+
service_environments=service_environments,
189202
debug=debug_log)
190203
load_subconfig(cwh_repo2docker_config_path)
191204

0 commit comments

Comments
 (0)