Skip to content

Commit

Permalink
feat: add validation for env vars (cannot be null or empty)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpage committed May 16, 2023
1 parent 93cce40 commit 142079e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ variable "gitlab_integration" {
variable "review_apps" {
description = "Configuration of the review apps of the application."
type = object({
enabled = optional(bool, false)
enabled = optional(bool, false)

# By default: delete review apps 0 hours after closing the PR
delete_on_close_enabled = optional(bool, true)
hours_before_delete_on_close = optional(string, "0")
delete_on_close_enabled = optional(bool, true)
hours_before_delete_on_close = optional(string, "0")

# By default: delete review apps after 5 days of inactivity (= no new deployment)
delete_stale_enabled = optional(bool, true)
hours_before_delete_stale = optional(string, "168")
delete_stale_enabled = optional(bool, true)
hours_before_delete_stale = optional(string, "168")

# By default: do not create review apps for PRs from forks
automatic_creation_from_forks_allowed = optional(bool, false)
Expand All @@ -110,9 +110,18 @@ variable "additionnal_collaborators" {
}

variable "environment" {
description = "Map of environment variables to set on the application"
description = "Map of environment variables to set on the application. Note that value of environment variables can be null or empty."
type = map(string)
default = {}
default = null

# validate that the map does not contain any null and empty values
validation {
condition = length([
for key, value in var.environment :
key if value == null || value == ""
]) == 0
error_message = "The map of environment variables must not contain any null or empty values."
}
}

variable "addons" {
Expand Down

0 comments on commit 142079e

Please sign in to comment.