generated from ipdxco/github-as-code
-
Notifications
You must be signed in to change notification settings - Fork 11
/
resources.tf
226 lines (187 loc) · 8.55 KB
/
resources.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
resource "github_membership" "this" {
for_each = local.resources.github_membership
username = each.value.username
role = each.value.role
lifecycle {
ignore_changes = []
prevent_destroy = true
}
}
resource "github_repository" "this" {
for_each = local.resources.github_repository
name = each.value.name
allow_auto_merge = try(each.value.allow_auto_merge, null)
allow_merge_commit = try(each.value.allow_merge_commit, null)
allow_rebase_merge = try(each.value.allow_rebase_merge, null)
allow_squash_merge = try(each.value.allow_squash_merge, null)
allow_update_branch = try(each.value.allow_update_branch, null)
archive_on_destroy = try(each.value.archive_on_destroy, null)
archived = try(each.value.archived, null)
auto_init = try(each.value.auto_init, null)
default_branch = try(each.value.default_branch, null)
delete_branch_on_merge = try(each.value.delete_branch_on_merge, null)
description = try(each.value.description, null)
gitignore_template = try(each.value.gitignore_template, null)
has_discussions = try(each.value.has_discussions, null)
has_downloads = try(each.value.has_downloads, null)
has_issues = try(each.value.has_issues, null)
has_projects = try(each.value.has_projects, null)
has_wiki = try(each.value.has_wiki, null)
homepage_url = try(each.value.homepage_url, null)
ignore_vulnerability_alerts_during_read = try(each.value.ignore_vulnerability_alerts_during_read, null)
is_template = try(each.value.is_template, null)
license_template = try(each.value.license_template, null)
merge_commit_message = try(each.value.merge_commit_message, null)
merge_commit_title = try(each.value.merge_commit_title, null)
squash_merge_commit_message = try(each.value.squash_merge_commit_message, null)
squash_merge_commit_title = try(each.value.squash_merge_commit_title, null)
topics = try(each.value.topics, null)
visibility = try(each.value.visibility, null)
vulnerability_alerts = try(each.value.vulnerability_alerts, null)
dynamic "security_and_analysis" {
for_each = try(each.value.security_and_analysis, [])
content {
dynamic "advanced_security" {
for_each = security_and_analysis.value["advanced_security"]
content {
status = advanced_security.value["status"]
}
}
dynamic "secret_scanning" {
for_each = security_and_analysis.value["secret_scanning"]
content {
status = secret_scanning.value["status"]
}
}
dynamic "secret_scanning_push_protection" {
for_each = security_and_analysis.value["secret_scanning_push_protection"]
content {
status = secret_scanning_push_protection.value["status"]
}
}
}
}
dynamic "pages" {
for_each = try(each.value.pages, [])
content {
cname = try(pages.value["cname"], null)
dynamic "source" {
for_each = pages.value["source"]
content {
branch = source.value["branch"]
path = try(source.value["path"], null)
}
}
}
}
dynamic "template" {
for_each = try(each.value.template, [])
content {
owner = template.value["owner"]
repository = template.value["repository"]
}
}
lifecycle {
ignore_changes = []
prevent_destroy = true
}
}
resource "github_repository_collaborator" "this" {
for_each = local.resources.github_repository_collaborator
depends_on = [github_repository.this]
repository = each.value.repository
username = each.value.username
permission = each.value.permission
lifecycle {
ignore_changes = []
}
}
resource "github_branch_protection" "this" {
for_each = local.resources.github_branch_protection
pattern = each.value.pattern
repository_id = lookup(each.value, "repository_id", lookup(lookup(github_repository.this, lower(lookup(each.value, "repository", "")), {}), "node_id", null))
allows_deletions = try(each.value.allows_deletions, null)
allows_force_pushes = try(each.value.allows_force_pushes, null)
blocks_creations = try(each.value.blocks_creations, null)
enforce_admins = try(each.value.enforce_admins, null)
lock_branch = try(each.value.lock_branch, null)
push_restrictions = try(each.value.push_restrictions, null)
require_conversation_resolution = try(each.value.require_conversation_resolution, null)
require_signed_commits = try(each.value.require_signed_commits, null)
required_linear_history = try(each.value.required_linear_history, null)
dynamic "required_pull_request_reviews" {
for_each = try(each.value.required_pull_request_reviews, [])
content {
dismiss_stale_reviews = try(required_pull_request_reviews.value["dismiss_stale_reviews"], null)
dismissal_restrictions = try(required_pull_request_reviews.value["dismissal_restrictions"], null)
pull_request_bypassers = try(required_pull_request_reviews.value["pull_request_bypassers"], null)
require_code_owner_reviews = try(required_pull_request_reviews.value["require_code_owner_reviews"], null)
required_approving_review_count = try(required_pull_request_reviews.value["required_approving_review_count"], null)
restrict_dismissals = try(required_pull_request_reviews.value["restrict_dismissals"], null)
}
}
dynamic "required_status_checks" {
for_each = try(each.value.required_status_checks, null)
content {
contexts = try(required_status_checks.value["contexts"], null)
strict = try(required_status_checks.value["strict"], null)
}
}
}
resource "github_team" "this" {
for_each = local.resources.github_team
name = each.value.name
parent_team_id = try(try(element(data.github_organization_teams.this[0].teams, index(data.github_organization_teams.this[0].teams.*.name, each.value.parent_team_id)).id, each.value.parent_team_id), null)
description = try(each.value.description, null)
privacy = try(each.value.privacy, null)
lifecycle {
ignore_changes = []
}
}
resource "github_team_repository" "this" {
for_each = local.resources.github_team_repository
depends_on = [github_repository.this]
repository = each.value.repository
permission = each.value.permission
team_id = lookup(each.value, "team_id", lookup(lookup(github_team.this, lower(lookup(each.value, "team", "")), {}), "id", null))
lifecycle {
ignore_changes = []
}
}
resource "github_team_membership" "this" {
for_each = local.resources.github_team_membership
username = each.value.username
role = each.value.role
team_id = lookup(each.value, "team_id", lookup(lookup(github_team.this, lower(lookup(each.value, "team", "")), {}), "id", null))
lifecycle {
ignore_changes = []
}
}
resource "github_repository_file" "this" {
for_each = local.resources.github_repository_file
repository = each.value.repository
file = each.value.file
content = each.value.content
# Since 5.25.0 the branch attribute defaults to the default branch of the repository
# branch = try(each.value.branch, null)
branch = lookup(each.value, "branch", lookup(lookup(github_repository.this, each.value.repository, {}), "default_branch", null))
overwrite_on_create = try(each.value.overwrite_on_create, true)
# Keep the defaults from 4.x
commit_author = try(each.value.commit_author, "GitHub")
commit_email = try(each.value.commit_email, "[email protected]")
commit_message = try(each.value.commit_message, "chore: Update ${each.value.file} [skip ci]")
lifecycle {
ignore_changes = []
}
}
resource "github_issue_label" "this" {
for_each = local.resources.github_issue_label
depends_on = [github_repository.this]
repository = each.value.repository
name = each.value.name
color = try(each.value.color, null)
description = try(each.value.description, null)
lifecycle {
ignore_changes = []
}
}