Skip to content

Commit e019273

Browse files
authored
refactor: update webhooks variable type and usage (#22)
- Changed the type of `webhooks` variable from `list` to `map` in `variables.tf` and `README.md`. - Updated the default value of `webhooks` variable from `[]` to `{}`. - Modified the `for_each` expression in `github_repository_webhook` resource in `main.tf` to iterate over the map of webhooks.
1 parent f5dfb70 commit e019273

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ No modules.
7272
| <a name="input_topics"></a> [topics](#input\_topics) | The topics of the repository | `list(string)` | `[]` | no |
7373
| <a name="input_visibility"></a> [visibility](#input\_visibility) | The visibility of the repository | `string` | `"private"` | no |
7474
| <a name="input_vulnerability_alerts"></a> [vulnerability\_alerts](#input\_vulnerability\_alerts) | Whether the repository has vulnerability alerts enabled | `bool` | `false` | no |
75-
| <a name="input_webhooks"></a> [webhooks](#input\_webhooks) | The URLs of the webhooks | <pre>list(object({<br> active = bool<br> events = list(string)<br> content_type = string<br> url = string<br> }))</pre> | `[]` | no |
75+
| <a name="input_webhooks"></a> [webhooks](#input\_webhooks) | Webhooks to configure for the repository | <pre>map(object({<br> active = bool<br> events = list(string)<br> content_type = string<br> url = string<br> }))</pre> | `{}` | no |
7676

7777
## Outputs
7878

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "github_branch_protection" "self" {
6666
}
6767

6868
resource "github_repository_webhook" "self" {
69-
for_each = toset(var.webhooks)
69+
for_each = { for webhook_key, webhook in var.webhooks : webhook_key => webhook }
7070

7171
active = each.value.active
7272
events = each.value.events

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ variable "vulnerability_alerts" {
182182
}
183183

184184
variable "webhooks" {
185-
default = []
186-
description = "The URLs of the webhooks"
187-
type = list(object({
185+
default = {}
186+
description = "Webhooks to configure for the repository"
187+
type = map(object({
188188
active = bool
189189
events = list(string)
190190
content_type = string

0 commit comments

Comments
 (0)