Commit e10b7075 authored by Daniele Venzano's avatar Daniele Venzano

environment key is optional in app descriptions

parent 6f21b732
...@@ -57,14 +57,15 @@ def _gen_environment(service, env_subst_dict, copts): ...@@ -57,14 +57,15 @@ def _gen_environment(service, env_subst_dict, copts):
""" Generate a dictionary containing the current cluster status (before the new container is spawned) """ Generate a dictionary containing the current cluster status (before the new container is spawned)
This information is used to substitute template strings in the environment variables.""" This information is used to substitute template strings in the environment variables."""
for env_name, env_value in service.description['environment']: if 'environment' in service.description:
try: for env_name, env_value in service.description['environment']:
env_value = env_value.format(**env_subst_dict) try:
except KeyError: env_value = env_value.format(**env_subst_dict)
error_msg = "Unknown variable in environment expression '{}', known variables are: {}".format(env_value, list(env_subst_dict.keys())) except KeyError:
service.set_error(error_msg) error_msg = "Unknown variable in environment expression '{}', known variables are: {}".format(env_value, list(env_subst_dict.keys()))
raise ZoeStartExecutionFatalException("Service {} has wrong environment expression") service.set_error(error_msg)
copts.add_env_variable(env_name, env_value) raise ZoeStartExecutionFatalException("Service {} has wrong environment expression")
copts.add_env_variable(env_name, env_value)
def _spawn_service(execution: Execution, service: Service, env_subst_dict: dict): def _spawn_service(execution: Execution, service: Service, env_subst_dict: dict):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment