Add default value and validation to agent_name variable

Ensure that agent_name defaults to an empty string, and introduce
validation to require it when subdomain is true. This aligns with
expected behavior and prevents misconfiguration.
pull/299/head
Muhammad Atif Ali 10 months ago
parent e11b19d33e
commit 6e757639ed

@ -13,10 +13,9 @@ A file browser for your workspace.
```tf ```tf
module "filebrowser" { module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder" source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18" version = "1.0.18"
agent_id = coder_agent.example.id agent_id = coder_agent.example.id
agent_name = "main"
} }
``` ```
@ -28,11 +27,10 @@ module "filebrowser" {
```tf ```tf
module "filebrowser" { module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder" source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18" version = "1.0.18"
agent_id = coder_agent.example.id agent_id = coder_agent.example.id
agent_name = "main" folder = "/home/coder/project"
folder = "/home/coder/project"
} }
``` ```
@ -43,7 +41,6 @@ module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder" source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18" version = "1.0.18"
agent_id = coder_agent.example.id agent_id = coder_agent.example.id
agent_name = "main"
database_path = ".config/filebrowser.db" database_path = ".config/filebrowser.db"
} }
``` ```

@ -21,6 +21,12 @@ data "coder_workspace_owner" "me" {}
variable "agent_name" { variable "agent_name" {
type = string type = string
description = "The name of the main deployment. (Used to build the subpath for coder_app.)" description = "The name of the main deployment. (Used to build the subpath for coder_app.)"
default = ""
validation {
# If subdomain is true, then agent_name must be set.
condition = var.subdomain ? var.agent_name != "" : true
error_message = "The agent_name must be set."
}
} }
variable "database_path" { variable "database_path" {

Loading…
Cancel
Save