From 860fbb1210306f1966da95cc80a1cca568576811 Mon Sep 17 00:00:00 2001 From: KRAIEM Taha Yassine Date: Wed, 12 May 2021 15:25:00 +0200 Subject: [PATCH] Changes: - enhanced env-vars injector --- api/env_handler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/env_handler.py b/api/env_handler.py index 2d338a486..b1c72ef97 100644 --- a/api/env_handler.py +++ b/api/env_handler.py @@ -1,5 +1,6 @@ from os import environ import json +import os with open('.chalice/config.json') as json_file: data = json.load(json_file) @@ -11,7 +12,9 @@ with open('.chalice/config.json') as json_file: with open(target) as stage_vars: data = json.load(stage_vars) except IOError: - pass + if not os.path.exists('chalicelib/.configs'): + os.makedirs('chalicelib/.configs') with open(target, 'w') as outfile: - json.dump({**data, **environ}, outfile, indent=2, sort_keys=True) + json.dump({**stages[s].get("environment_variables", {}), **data, **environ}, + outfile, indent=2, sort_keys=True) print(f"injected env-vars to {target}")