mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Only update existing manifest variables when adding env secrets
Changes generate manifest script to parse variables file as YAML and only add variables to the manifest if they're already listed in the `env` section. This allows us to use a single variables file for all applications and avoid duplicating secrets across multiple files while adding only the relevant secrets to the application manifest.
This commit is contained in:
@@ -39,7 +39,7 @@ def load_variables(vars_files):
|
||||
variables = {}
|
||||
for vars_file in vars_files:
|
||||
with open(vars_file) as f:
|
||||
variables = merge_dicts(variables, json.load(f))
|
||||
variables = merge_dicts(variables, yaml.load(f))
|
||||
|
||||
return {
|
||||
k.upper(): json.dumps(v) if isinstance(v, (dict, list)) else v
|
||||
@@ -53,10 +53,13 @@ def paas_manifest(manifest_file, *vars_files):
|
||||
manifest = load_manifest(manifest_file)
|
||||
variables = load_variables(vars_files)
|
||||
|
||||
manifest['env'].update(variables)
|
||||
for key in manifest.get('env', {}):
|
||||
if key in variables:
|
||||
manifest['env'][key] = variables[key]
|
||||
|
||||
return yaml.dump(manifest, default_flow_style=False, allow_unicode=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print('---')
|
||||
print(paas_manifest(*sys.argv[1:]))
|
||||
|
||||
Reference in New Issue
Block a user