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

Add per template override of overlay vars #933

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

seanhinde
Copy link
Contributor

This PR adds the possibility to have a different overlay_vars file applied to each template line in a release. This allows creation of multiple output files with different content from a single template file.

It implements the discussion from #757

So from a single template file e.g. priv/app.config containing

{param, {{var}}}.

it will be possible to generate multiple output files in the same release:

{template, "priv/app.config", "host1/app.config", "host1_overlay_vars.config"},
{template, "priv/app.config", "host2/app.config", "host2_overlay_vars.config"},

where host1_overlay_vars.config could contain

{var, "host 1 config"}.

and host2_overlay_vars.config could contain

{var, "host 2 config"}.

generating two output files.

This PR includes a test case.

There is one change here I'm not sure about. When there is also a global overlay_vars file it would be nice if the template specific variables could override the global ones. In the implementation I've re-used rex_overlay:read_overlay_vars/3 but that function always makes newer variables hidden if they are already set. I've changed its behaviour, but this could cause breakage.

In my case I don't need this - I always set all the vars in each vars file, but it seems useful. Could also be fixed by making a copy of the read_overlay_vars function with the different ordering. I'd welcome some input here.

Added test suite for overlay overrides

Changed order of applying multiple overrides
@ferd ferd merged commit a772620 into erlware:main Mar 13, 2024
@ferd
Copy link
Collaborator

ferd commented Mar 13, 2024

I've merged this because I agree we should ideally see local vars take over the global ones. I do share the risk around breakage there, but I'm not quite sure there's anything we can do to de-risk that.

@seanhinde
Copy link
Contributor Author

Tremendous, thanks very much

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

Successfully merging this pull request may close these issues.

2 participants