Commit 2bbc903
committed
fix(mixins): recurse into nested components and only update existing copies
Closes #47.
The `mixins:update-all` task previously assumed a flat `./components/*`
layout, so nested deployable instances like `aws-iam/delegated-tf-role`
were never updated.
It also unconditionally copied the mixin into every top-level component
directory, which is wrong: a given mixin is not universally applicable
(e.g. the `secrets.sops.tf` mixin only belongs in components that actually
consume SOPS secrets). Copying it everywhere creates unused files that
have to be deleted by hand.
Changes:
- Locate destinations by recursively finding existing copies of the named
mixin under `./components/` (`find ... -type f -name <file>`). A
component opts in to a mixin by having a copy of it on disk; this task
only keeps those existing copies in sync. To adopt a mixin in a new
component, copy it in manually once — that becomes the explicit opt-in
and future `update-all` runs will track the template.
- Recursion picks up nested instance layouts (e.g.
`components/aws-iam/delegated-tf-role/<file>`) automatically.
- Prune `.terraform/` and `.terragrunt-cache/` so vendored child-module
copies that Terraform/Terragrunt drop on disk during init are not
overwritten.
- Set `dir: "{{.USER_WORKING_DIR}}"` so `./mixins/` and `./components/`
resolve from where the user invoked `task`, not from the included
taskfile's own directory.
- Drop the `generates:` glob — it cannot express nested outputs and was
causing Task to falsely treat the task as up-to-date.
- Rewrite the loop to avoid `read -d ''` (not supported by Task's
mvdan/sh interpreter).1 parent dc2bbef commit 2bbc903
1 file changed
Lines changed: 17 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
6 | 19 | | |
7 | 20 | | |
8 | 21 | | |
9 | | - | |
10 | | - | |
11 | 22 | | |
12 | 23 | | |
13 | | - | |
14 | | - | |
15 | 24 | | |
16 | 25 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
0 commit comments