From e90ed5654fdb0fc19706c23b9381b1bf07b79aca Mon Sep 17 00:00:00 2001 From: Kenny Leung Date: Tue, 5 Nov 2024 13:14:30 -0800 Subject: [PATCH] support for adding labels (#618) Signed-off-by: Kenny Leung --- modules/cron/README.md | 1 + modules/cron/main.tf | 1 + modules/cron/variables.tf | 6 ++++++ modules/github-bots/README.md | 1 + modules/github-bots/main.tf | 3 ++- modules/github-bots/variables.tf | 6 ++++++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/cron/README.md b/modules/cron/README.md index 8f9fc310..b3d70317 100644 --- a/modules/cron/README.md +++ b/modules/cron/README.md @@ -107,6 +107,7 @@ No modules. | [importpath](#input\_importpath) | The import path that contains the cron application. | `string` | n/a | yes | | [invokers](#input\_invokers) | List of iam members invoker perimssions to invoke the job. | `list(string)` | `[]` | no | | [ko\_build\_env](#input\_ko\_build\_env) | A list of custom environment variables to pass to the ko build. | `list(string)` | `[]` | no | +| [labels](#input\_labels) | Labels to apply to the job. | `map(string)` | `{}` | no | | [max\_retries](#input\_max\_retries) | The maximum number of times to retry the job. | `number` | `3` | no | | [memory](#input\_memory) | The memory limit for the job. | `string` | `"512Mi"` | no | | [name](#input\_name) | Name to prefix to created resources. | `any` | n/a | yes | diff --git a/modules/cron/main.tf b/modules/cron/main.tf index 459c419c..7004488b 100644 --- a/modules/cron/main.tf +++ b/modules/cron/main.tf @@ -60,6 +60,7 @@ resource "google_cloud_run_v2_job" "job" { template { parallelism = var.parallelism task_count = var.task_count + labels = var.labels template { execution_environment = var.execution_environment diff --git a/modules/cron/variables.tf b/modules/cron/variables.tf index e2286293..81591aa4 100644 --- a/modules/cron/variables.tf +++ b/modules/cron/variables.tf @@ -203,3 +203,9 @@ variable "deletion_protection" { description = "Whether to enable delete protection for the service." default = true } + +variable "labels" { + description = "Labels to apply to the job." + type = map(string) + default = {} +} diff --git a/modules/github-bots/README.md b/modules/github-bots/README.md index 59b47663..ba6402e8 100644 --- a/modules/github-bots/README.md +++ b/modules/github-bots/README.md @@ -115,6 +115,7 @@ No requirements. | [extra\_filter\_not\_has\_attributes](#input\_extra\_filter\_not\_has\_attributes) | Optional additional prefixes to check for presence. | `list(string)` | `[]` | no | | [extra\_filter\_prefix](#input\_extra\_filter\_prefix) | Optional additional prefixes for filtering events. | `map(string)` | `{}` | no | | [github-event](#input\_github-event) | The GitHub event type to subscribe to. | `string` | n/a | yes | +| [labels](#input\_labels) | Labels to apply to the service. | `map(string)` | `{}` | no | | [name](#input\_name) | The name of the bot. | `string` | n/a | yes | | [notification\_channels](#input\_notification\_channels) | List of notification channels to alert. | `list(string)` | n/a | yes | | [project\_id](#input\_project\_id) | Project ID to create resources in. | `string` | n/a | yes | diff --git a/modules/github-bots/main.tf b/modules/github-bots/main.tf index e5f544e8..e7e8b057 100644 --- a/modules/github-bots/main.tf +++ b/modules/github-bots/main.tf @@ -16,8 +16,9 @@ module "service" { project_id = var.project_id regions = var.regions - service_account = var.service_account_email == "" ? google_service_account.sa[0].email : var.service_account_email + labels = var.labels + service_account = var.service_account_email == "" ? google_service_account.sa[0].email : var.service_account_email egress = "PRIVATE_RANGES_ONLY" // Makes GitHub API calls diff --git a/modules/github-bots/variables.tf b/modules/github-bots/variables.tf index 83261ff1..e4f1ec3b 100644 --- a/modules/github-bots/variables.tf +++ b/modules/github-bots/variables.tf @@ -129,3 +129,9 @@ variable "service_account_email" { type = string default = "" } + +variable "labels" { + description = "Labels to apply to the service." + type = map(string) + default = {} +}