Skip to content

Commit

Permalink
refactor: update webhooks variable type and usage (#22)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
erikreinert authored Jul 14, 2024
1 parent f5dfb70 commit e019273
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ No modules.
| <a name="input_topics"></a> [topics](#input\_topics) | The topics of the repository | `list(string)` | `[]` | no |
| <a name="input_visibility"></a> [visibility](#input\_visibility) | The visibility of the repository | `string` | `"private"` | no |
| <a name="input_vulnerability_alerts"></a> [vulnerability\_alerts](#input\_vulnerability\_alerts) | Whether the repository has vulnerability alerts enabled | `bool` | `false` | no |
| <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 |
| <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 |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e019273

Please sign in to comment.