Skip to content
Snippets Groups Projects
Commit acba44a6 authored by Tim Kreuzer's avatar Tim Kreuzer
Browse files

add store_environment_in_file option, default is false

parent d8bc3255
No related branches found
No related tags found
No related merge requests found
......@@ -297,6 +297,15 @@ class UnicoreSpawner(ForwardBaseSpawner):
bss_notification_config = self.bss_notification_config
return bss_notification_config
store_environment_in_file = Boolean(
config=True,
default_value=False,
help="""
Store all environment variables in a .env file, instead of storing them in the job_description directly.
Might be useful to hide them from other users.
""",
)
download_max_bytes = Integer(
config=True,
default_value=4096,
......@@ -599,6 +608,17 @@ class UnicoreSpawner(ForwardBaseSpawner):
self.log.debug(f"{self._log_name} - Remove {key} from env")
del env[key]
jd_env.update(env)
if self.store_environment_in_file:
env_file = "#!/bin/bash"
for key, value in jd_env.items():
env_file += f"export {key}={value}\n"
if "Imports" not in job_description.keys():
job_description["Imports"] = {}
job_description["Imports"][".env"] = env_file
if "Environment" in job_description.keys():
del job_description["Environment"]
else:
job_description["Environment"] = jd_env
client = await self._get_client()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment