Handle optional config-file

This commit is contained in:
David Boreham 2023-11-28 21:11:11 -07:00
parent cd8a6ce1f3
commit afa6e64ad3

View File

@ -301,15 +301,16 @@ def init_operation(deploy_command_context, stack, deployer_type, config,
new_config = config_variables new_config = config_variables
merged_config = {**new_config, **orig_config} merged_config = {**new_config, **orig_config}
spec_file_content.update({"config": merged_config}) spec_file_content.update({"config": merged_config})
config_file_path = Path(config_file) if config_file:
if not config_file_path.exists(): config_file_path = Path(config_file)
error_exit(f"config file: {config_file} does not exist") if not config_file_path.exists():
config_file_variables = env_var_map_from_file(config_file_path) error_exit(f"config file: {config_file} does not exist")
if config_file_variables: config_file_variables = env_var_map_from_file(config_file_path)
orig_config = spec_file_content.get("config", {}) if config_file_variables:
new_config = config_file_variables orig_config = spec_file_content.get("config", {})
merged_config = {**new_config, **orig_config} new_config = config_file_variables
spec_file_content.update({"config": merged_config}) merged_config = {**new_config, **orig_config}
spec_file_content.update({"config": merged_config})
if opts.o.debug: if opts.o.debug:
print(f"Creating spec file for stack: {stack} with content: {spec_file_content}") print(f"Creating spec file for stack: {stack} with content: {spec_file_content}")