Skip to content

Commit 72ac758

Browse files
committed
Add keepvars_extra to whitelist more environment.
- Existing keepvars will whitelist environment variables, but is all-or-nothing: you can't append to existing required environemnt variables that JupyterHub requires. - This allows a comma separated list of the same format as req_keepvars that gets appended to keepvars, with one extra comma between them.
1 parent c320f05 commit 72ac758

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

batchspawner/batchspawner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ def _req_homedir_default(self):
143143
def _req_keepvars_default(self):
144144
return ','.join(self.get_env().keys())
145145

146+
req_keepvars_extra = Unicode(
147+
help="Extra environment variables which should be configured, "
148+
"added to the defaults in keepvars, "
149+
"comma separated list.")
150+
151+
146152
batch_script = Unicode('', \
147153
help="Template for job submission script. Traits on this class named like req_xyz "
148154
"will be substituted in the template for {xyz} using string.Formatter. "
@@ -164,6 +170,8 @@ def get_req_subvars(self):
164170
subvars = {}
165171
for t in reqlist:
166172
subvars[t[4:]] = getattr(self, t)
173+
if subvars.get('keepvars_extra'):
174+
subvars['keepvars'] += ',' + subvars['keepvars_extra']
167175
return subvars
168176

169177
batch_submit_cmd = Unicode('', \

0 commit comments

Comments
 (0)