From 6e757639edd40a1e95461ccf162ab7e694624476 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 24 Sep 2024 11:02:55 +0500 Subject: [PATCH] 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. --- filebrowser/README.md | 17 +++++++---------- filebrowser/main.tf | 6 ++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index dd26d27..e92560b 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -13,10 +13,9 @@ A file browser for your workspace. ```tf module "filebrowser" { - source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.18" - agent_id = coder_agent.example.id - agent_name = "main" + source = "registry.coder.com/modules/filebrowser/coder" + version = "1.0.18" + agent_id = coder_agent.example.id } ``` @@ -28,11 +27,10 @@ module "filebrowser" { ```tf module "filebrowser" { - source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.18" - agent_id = coder_agent.example.id - agent_name = "main" - folder = "/home/coder/project" + source = "registry.coder.com/modules/filebrowser/coder" + version = "1.0.18" + agent_id = coder_agent.example.id + folder = "/home/coder/project" } ``` @@ -43,7 +41,6 @@ module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" version = "1.0.18" agent_id = coder_agent.example.id - agent_name = "main" database_path = ".config/filebrowser.db" } ``` diff --git a/filebrowser/main.tf b/filebrowser/main.tf index e6b88c6..422dfe7 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -21,6 +21,12 @@ data "coder_workspace_owner" "me" {} variable "agent_name" { type = string 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" {