Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--plugin-secret over-rides existing metadata.json plugin config #724

Closed
simonw opened this issue Apr 10, 2020 · 3 comments
Closed

--plugin-secret over-rides existing metadata.json plugin config #724

simonw opened this issue Apr 10, 2020 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Apr 10, 2020

This means if you use --plugin-secret at all (with e.g. publish cloudrun) any existing plugin configuration in your metadata.json will be ignored.

if plugin_secret:
extra_metadata["plugins"] = {}
for plugin_name, plugin_setting, setting_value in plugin_secret:
environment_variable = (
"{}_{}".format(plugin_name, plugin_setting)
.upper()
.replace("-", "_")
)
environment_variables[environment_variable] = setting_value
extra_metadata["plugins"].setdefault(plugin_name, {})[
plugin_setting
] = {"$env": environment_variable}

@simonw
Copy link
Owner Author

simonw commented Apr 10, 2020

Actually that code isn't the problem, since extra_metadata has not yet been read from metadata.json at that point.

The bug is here:

if metadata:
metadata_content = parse_metadata(metadata.read())
else:
metadata_content = {}
for key, value in extra_metadata.items():
if value:
metadata_content[key] = value

I need to merge dictionaries in a smarter way.

@simonw
Copy link
Owner Author

simonw commented Apr 10, 2020

Lot's of recipes for deep dictionary merge on https://stackoverflow.com/q/7204805/6083

@simonw
Copy link
Owner Author

simonw commented Apr 10, 2020

I think I'll use https://github.com/clarketm/mergedeep (MIT license)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant