|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -# Import existing main branch protections into Terraform state |
| 15 | +# Import existing branch protections into Terraform state |
16 | 16 | # These protections already exist on GitHub and need to be imported |
17 | 17 | # so Terraform can manage them going forward. |
18 | 18 | # |
| 19 | +# Uses for_each to dynamically import based on tektoncd_repos list. |
19 | 20 | # After successful import, these blocks can be removed. |
20 | 21 |
|
21 | 22 | import { |
22 | | - to = github_branch_protection.main["dashboard"] |
23 | | - id = "dashboard:main" |
| 23 | + for_each = toset(local.tektoncd_repos) |
| 24 | + to = github_branch_protection.main[each.key] |
| 25 | + id = "${each.key}:main" |
24 | 26 | } |
25 | 27 |
|
26 | 28 | import { |
27 | | - to = github_branch_protection.main["pipeline"] |
28 | | - id = "pipeline:main" |
29 | | -} |
30 | | - |
31 | | -import { |
32 | | - to = github_branch_protection.main["operator"] |
33 | | - id = "operator:main" |
34 | | -} |
35 | | - |
36 | | -import { |
37 | | - to = github_branch_protection.main["mcp-server"] |
38 | | - id = "mcp-server:main" |
39 | | -} |
40 | | - |
41 | | -import { |
42 | | - to = github_branch_protection.main["triggers"] |
43 | | - id = "triggers:main" |
44 | | -} |
45 | | - |
46 | | -import { |
47 | | - to = github_branch_protection.main["cli"] |
48 | | - id = "cli:main" |
49 | | -} |
50 | | - |
51 | | -import { |
52 | | - to = github_branch_protection.main["pruner"] |
53 | | - id = "pruner:main" |
54 | | -} |
55 | | - |
56 | | -import { |
57 | | - to = github_branch_protection.main["chains"] |
58 | | - id = "chains:main" |
59 | | -} |
60 | | - |
61 | | -import { |
62 | | - to = github_branch_protection.main["hub"] |
63 | | - id = "hub:main" |
64 | | -} |
65 | | - |
66 | | -import { |
67 | | - to = github_branch_protection.main["results"] |
68 | | - id = "results:main" |
69 | | -} |
70 | | - |
71 | | -import { |
72 | | - to = github_branch_protection.main["plumbing"] |
73 | | - id = "plumbing:main" |
74 | | -} |
75 | | - |
76 | | -# Import existing release branch protections (release-v*) |
77 | | -# These were created in the first terraform-branch-protection pipeline run. |
78 | | -# |
79 | | -# After successful import, these blocks can be removed. |
80 | | - |
81 | | -import { |
82 | | - to = github_branch_protection.releases["dashboard"] |
83 | | - id = "dashboard:release-v*" |
84 | | -} |
85 | | - |
86 | | -import { |
87 | | - to = github_branch_protection.releases["pipeline"] |
88 | | - id = "pipeline:release-v*" |
89 | | -} |
90 | | - |
91 | | -import { |
92 | | - to = github_branch_protection.releases["operator"] |
93 | | - id = "operator:release-v*" |
94 | | -} |
95 | | - |
96 | | -import { |
97 | | - to = github_branch_protection.releases["mcp-server"] |
98 | | - id = "mcp-server:release-v*" |
99 | | -} |
100 | | - |
101 | | -import { |
102 | | - to = github_branch_protection.releases["triggers"] |
103 | | - id = "triggers:release-v*" |
104 | | -} |
105 | | - |
106 | | -import { |
107 | | - to = github_branch_protection.releases["cli"] |
108 | | - id = "cli:release-v*" |
109 | | -} |
110 | | - |
111 | | -import { |
112 | | - to = github_branch_protection.releases["pruner"] |
113 | | - id = "pruner:release-v*" |
114 | | -} |
115 | | - |
116 | | -import { |
117 | | - to = github_branch_protection.releases["chains"] |
118 | | - id = "chains:release-v*" |
119 | | -} |
120 | | - |
121 | | -import { |
122 | | - to = github_branch_protection.releases["hub"] |
123 | | - id = "hub:release-v*" |
124 | | -} |
125 | | - |
126 | | -import { |
127 | | - to = github_branch_protection.releases["results"] |
128 | | - id = "results:release-v*" |
129 | | -} |
130 | | - |
131 | | -import { |
132 | | - to = github_branch_protection.releases["plumbing"] |
133 | | - id = "plumbing:release-v*" |
| 29 | + for_each = toset(local.tektoncd_repos) |
| 30 | + to = github_branch_protection.releases[each.key] |
| 31 | + id = "${each.key}:release-v*" |
134 | 32 | } |
0 commit comments