From 01949660bbf354d39b461994f7fd193acfc13170 Mon Sep 17 00:00:00 2001 From: KRAIEM Taha Yassine Date: Wed, 12 May 2021 19:05:15 +0200 Subject: [PATCH] Changes: - changed env-handler logic --- api/env_handler.py | 17 ++++------------- ee/api/env_handler.py | 14 ++++---------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/api/env_handler.py b/api/env_handler.py index b1c72ef97..3eb7e2ad8 100644 --- a/api/env_handler.py +++ b/api/env_handler.py @@ -1,20 +1,11 @@ from os import environ import json -import os with open('.chalice/config.json') as json_file: data = json.load(json_file) stages = data.get("stages", {}) for s in stages.keys(): - target = f'chalicelib/.configs/{stages[s].get("environment_variables", {}).get("stage", s)}.json' - data = {} - try: - with open(target) as stage_vars: - data = json.load(stage_vars) - except IOError: - if not os.path.exists('chalicelib/.configs'): - os.makedirs('chalicelib/.configs') - with open(target, 'w') as outfile: - json.dump({**stages[s].get("environment_variables", {}), **data, **environ}, - outfile, indent=2, sort_keys=True) - print(f"injected env-vars to {target}") + data["stages"][s]["environment_variables"] = {**stages[s].get("environment_variables", {}), **environ} +with open('.chalice/config.json', 'w') as outfile: + json.dump(data, outfile, indent=2, sort_keys=True) + print("override config.json") diff --git a/ee/api/env_handler.py b/ee/api/env_handler.py index 2d338a486..3eb7e2ad8 100644 --- a/ee/api/env_handler.py +++ b/ee/api/env_handler.py @@ -5,13 +5,7 @@ with open('.chalice/config.json') as json_file: data = json.load(json_file) stages = data.get("stages", {}) for s in stages.keys(): - target = f'chalicelib/.configs/{stages[s].get("environment_variables", {}).get("stage", s)}.json' - data = {} - try: - with open(target) as stage_vars: - data = json.load(stage_vars) - except IOError: - pass - with open(target, 'w') as outfile: - json.dump({**data, **environ}, outfile, indent=2, sort_keys=True) - print(f"injected env-vars to {target}") + data["stages"][s]["environment_variables"] = {**stages[s].get("environment_variables", {}), **environ} +with open('.chalice/config.json', 'w') as outfile: + json.dump(data, outfile, indent=2, sort_keys=True) + print("override config.json")