From 0e377d6a01169ab5851bdbc431abcba730a4569b Mon Sep 17 00:00:00 2001 From: Erik Reinert <4638629+erikreinert@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:04:36 -0700 Subject: [PATCH] refactor: update webhooks variable type and usage - 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. --- README.md | 2 +- main.tf | 2 +- variables.tf | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 736041f..3832127 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ No modules. | [topics](#input\_topics) | The topics of the repository | `list(string)` | `[]` | no | | [visibility](#input\_visibility) | The visibility of the repository | `string` | `"private"` | no | | [vulnerability\_alerts](#input\_vulnerability\_alerts) | Whether the repository has vulnerability alerts enabled | `bool` | `false` | no | -| [webhooks](#input\_webhooks) | The URLs of the webhooks |
list(object({
active = bool
events = list(string)
content_type = string
url = string
}))
| `[]` | no | +| [webhooks](#input\_webhooks) | Webhooks to configure for the repository |
map(object({
active = bool
events = list(string)
content_type = string
url = string
}))
| `{}` | no | ## Outputs diff --git a/main.tf b/main.tf index 073d763..1f0f8d8 100644 --- a/main.tf +++ b/main.tf @@ -66,7 +66,7 @@ resource "github_branch_protection" "self" { } resource "github_repository_webhook" "self" { - for_each = toset(var.webhooks) + for_each = { for webhook_key, webhook in var.webhooks : webhook_key => webhook } active = each.value.active events = each.value.events diff --git a/variables.tf b/variables.tf index 0a53d0a..bac4d37 100644 --- a/variables.tf +++ b/variables.tf @@ -182,9 +182,9 @@ variable "vulnerability_alerts" { } variable "webhooks" { - default = [] - description = "The URLs of the webhooks" - type = list(object({ + default = {} + description = "Webhooks to configure for the repository" + type = map(object({ active = bool events = list(string) content_type = string