This pull request implements layering of the ./mailer-templates/ directory using similar logic to how policies are layered, to allow sourcing c7n-mailer custom templates from multiple policy repositories with overrides. This is implemented in policygen.
The algorithm is as follows:
Walk through the configured policy_source_paths directories in order.
For each one that has a mailer-templates subdirectory, add the names of all regular files in it to a dictionary of filename to path. This ensures that, for a given filename, it comes from the last directory in policy_source_paths order where it exists.
Each file in the resulting dict will be copied from its source location to ./mailer-templates/. Any files that already exist there will not be overwritten.
Testing Done
Unit tests.
Set up a few different example directory layouts, ran policygen, and manually verified that the generated files were correct.
Description
This pull request implements layering of the
./mailer-templates/
directory using similar logic to how policies are layered, to allow sourcing c7n-mailer custom templates from multiple policy repositories with overrides. This is implemented in policygen.The algorithm is as follows:
policy_source_paths
directories in order.mailer-templates
subdirectory, add the names of all regular files in it to a dictionary of filename to path. This ensures that, for a given filename, it comes from the last directory inpolicy_source_paths
order where it exists../mailer-templates/
. Any files that already exist there will not be overwritten.Testing Done