gruntwork-io / boilerplate

A tool for generating files and folders ("boilerplate") from a set of templates
https://www.gruntwork.io
Mozilla Public License 2.0
157 stars 12 forks source link

Add for_each #134

Closed brikis98 closed 1 year ago

brikis98 commented 1 year ago

Description

This PR adds for_each and for_each_reference support to the dependency block of boilerplate. If you pass in a list to these attributes, instead of creating the dependency once, boilerpalte will loop over each item in the for_each list, and run the dependency once for each of those items. You can access the current item in the loop using __each__.

The main use case for this is to generate sub-folders and files dynamically: e.g., in https://github.com/gruntwork-io/prototypes/pull/361, I use this to generate environments (dev, stage, prod) dynamically, based on which environments the user asked for.

Bonus fix: remove Rho from CODEOWNERS; GitHub was showing an error about that.

TODOs

Read the Gruntwork contribution guidelines.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

brikis98 commented 1 year ago

OK, this is now ready for review. I added docs and examples; and by virtue of putting the examples and some test fixtures in the right folders, this also automatically adds tests.

brikis98 commented 1 year ago

Hm, there seems to be some issue preventing me from merging. Might be related to: https://github.com/orgs/community/discussions/58535. The suggestion there is to close and re-open the PR... Let me try that.

brikis98 commented 1 year ago

That... did not work. WTF.

brikis98 commented 1 year ago

Grr, no time to deal with this, will temporarily disable branch protection and merge.