From b0b0d55a1a4d40b085c311175d302499f56e0665 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:20:08 +0000 Subject: [PATCH 01/21] filebrowser: allow to use subdomain = false --- filebrowser/README.md | 13 +++++++++++++ filebrowser/main.tf | 25 +++++++++++++++++++++++-- filebrowser/run.sh | 7 +++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 28813764..e3a3d22f 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -44,3 +44,16 @@ module "filebrowser" { database_path = ".config/filebrowser.db" } ``` + +### Serve from the same domain (no subdomain) + +Make sure to set both workspace_name and owner_name. + +```tf +module "filebrowser" { + source = "registry.coder.com/modules/filebrowser/coder" + agent_id = coder_agent.main.id + workspace_name = data.coder_workspace.me.name + owner_name = data.coder_workspace_owner.me.name +} +``` \ No newline at end of file diff --git a/filebrowser/main.tf b/filebrowser/main.tf index a07072b9..00659023 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -14,6 +14,24 @@ variable "agent_id" { description = "The ID of a Coder agent." } +variable "workspace_name" { + type = string + default = "" + description = "Set this and owner_name to serve filebrowser from subdirectory." +} + +variable "owner_name" { + type = string + default = "" + description = "Set this and workspace_name to serve filebrowser from subdirectory." +} + +variable "resource_name" { + type = string + default = "main" + description = "The name of the main deployment. (Used to build the subdirectory of the module.)" +} + variable "database_path" { type = string description = "The path to the filebrowser database." @@ -67,7 +85,10 @@ resource "coder_script" "filebrowser" { PORT : var.port, FOLDER : var.folder, LOG_PATH : var.log_path, - DB_PATH : var.database_path + DB_PATH : var.database_path, + WORKSPACE_NAME : var.workspace_name, + OWNER_NAME : var.owner_name, + RESOURCE_NAME : var.resource_name }) run_on_start = true } @@ -78,7 +99,7 @@ resource "coder_app" "filebrowser" { display_name = "File Browser" url = "http://localhost:${var.port}" icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" - subdomain = true + subdomain = var.owner_name == "" && var.workspace_name == "" share = var.share order = var.order } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 8744edba..e998c607 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -17,6 +17,13 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then DB_FLAG=" -d ${DB_PATH}" fi +# set baseurl if subdomain = false (owner_name and workspace_name is set), else reset to "" for use with subdomain = true +if [ "${OWNER_NAME}" != "" ] && [ "${WORKSPACE_NAME}" != "" ]; then + filebrowser config set --baseurl "/@${OWNER_NAME}/${WORKSPACE_NAME}.${RESOURCE_NAME}/apps/filebrowser" > ${LOG_PATH} 2>&1 +else + filebrowser config set --baseurl "" > ${LOG_PATH} 2>&1 +fi + printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" From 91a0b009525ac53936ccb93e690bbc44d67ccf4b Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:40:19 +0200 Subject: [PATCH 02/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 00659023..309a873c 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -88,7 +88,8 @@ resource "coder_script" "filebrowser" { DB_PATH : var.database_path, WORKSPACE_NAME : var.workspace_name, OWNER_NAME : var.owner_name, - RESOURCE_NAME : var.resource_name + AGENT_NAME : var.agent_name + SUBDOMAIN : var.subdomain }) run_on_start = true } From deadbb6296f3db411233de3f3f942a4bf9212b5b Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:40:49 +0200 Subject: [PATCH 03/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 309a873c..6179383d 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -26,10 +26,10 @@ variable "owner_name" { description = "Set this and workspace_name to serve filebrowser from subdirectory." } -variable "resource_name" { +variable "agent_name" { type = string - default = "main" - description = "The name of the main deployment. (Used to build the subdirectory of the module.)" + default = "" + description = "The name of the main deployment. (Used to build the subpath for coder_app.)" } variable "database_path" { From 2c304426e531122fd8e822d7d06df0adc91e27e9 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:43:52 +0200 Subject: [PATCH 04/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 6179383d..b17e419b 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -100,7 +100,7 @@ resource "coder_app" "filebrowser" { display_name = "File Browser" url = "http://localhost:${var.port}" icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" - subdomain = var.owner_name == "" && var.workspace_name == "" + subdomain = var.subdomain share = var.share order = var.order } From 1a896e74f73df0bf5ca6d23aafcbea58d415b2cc Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:43:59 +0200 Subject: [PATCH 05/21] Update filebrowser/run.sh Co-authored-by: Muhammad Atif Ali --- filebrowser/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filebrowser/run.sh b/filebrowser/run.sh index e998c607..7a5c9379 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -17,8 +17,8 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then DB_FLAG=" -d ${DB_PATH}" fi -# set baseurl if subdomain = false (owner_name and workspace_name is set), else reset to "" for use with subdomain = true -if [ "${OWNER_NAME}" != "" ] && [ "${WORKSPACE_NAME}" != "" ]; then +# set baseurl if subdomain = false +if [ "${SUBDOMAIN}" == "false" ]; then filebrowser config set --baseurl "/@${OWNER_NAME}/${WORKSPACE_NAME}.${RESOURCE_NAME}/apps/filebrowser" > ${LOG_PATH} 2>&1 else filebrowser config set --baseurl "" > ${LOG_PATH} 2>&1 From 772ba22a98c061b3f7364a140d3f1d8cf1b2d46c Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:44:06 +0200 Subject: [PATCH 06/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index b17e419b..db79f810 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -14,10 +14,8 @@ variable "agent_id" { description = "The ID of a Coder agent." } -variable "workspace_name" { - type = string - default = "" - description = "Set this and owner_name to serve filebrowser from subdirectory." +data "coder_workspace" "me" { + count = var.subdomain } variable "owner_name" { From 23417ce3048f8d8e0293bcca9af86072cefbfa33 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:44:17 +0200 Subject: [PATCH 07/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index db79f810..4e3a8412 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -18,10 +18,8 @@ data "coder_workspace" "me" { count = var.subdomain } -variable "owner_name" { - type = string - default = "" - description = "Set this and workspace_name to serve filebrowser from subdirectory." +data "coder_workspace_owner" "me" { + count = var.subdomain } variable "agent_name" { From e8b408d22f65fd2f554c3c8ed95b30faca1f80de Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:44:25 +0200 Subject: [PATCH 08/21] Update filebrowser/main.tf Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 4e3a8412..338eaac5 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -82,8 +82,8 @@ resource "coder_script" "filebrowser" { FOLDER : var.folder, LOG_PATH : var.log_path, DB_PATH : var.database_path, - WORKSPACE_NAME : var.workspace_name, - OWNER_NAME : var.owner_name, + WORKSPACE_NAME : data.coder_workspace.me.name, + OWNER_NAME : data.coder_workspace_owner.me.name, AGENT_NAME : var.agent_name SUBDOMAIN : var.subdomain }) From 71624cff0fa6b976da9e809b9441e6939637cbf7 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:51:58 +0200 Subject: [PATCH 09/21] assemble base path inside terraform --- filebrowser/main.tf | 7 +++---- filebrowser/run.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 338eaac5..dc93b534 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -82,10 +82,9 @@ resource "coder_script" "filebrowser" { FOLDER : var.folder, LOG_PATH : var.log_path, DB_PATH : var.database_path, - WORKSPACE_NAME : data.coder_workspace.me.name, - OWNER_NAME : data.coder_workspace_owner.me.name, - AGENT_NAME : var.agent_name - SUBDOMAIN : var.subdomain + SUBDOMAIN : var.subdomain, + SERVER_BASE_PATH : format("/@%s/%s.%s/apps/vscode-web/", + data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name), }) run_on_start = true } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 7a5c9379..ef94ffb8 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -19,7 +19,7 @@ fi # set baseurl if subdomain = false if [ "${SUBDOMAIN}" == "false" ]; then - filebrowser config set --baseurl "/@${OWNER_NAME}/${WORKSPACE_NAME}.${RESOURCE_NAME}/apps/filebrowser" > ${LOG_PATH} 2>&1 + filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1 else filebrowser config set --baseurl "" > ${LOG_PATH} 2>&1 fi From be53031fa3137f603cc2fac958dcdf18815c4158 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:55:31 +0200 Subject: [PATCH 10/21] use correct app name --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index dc93b534..2e737566 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -83,7 +83,7 @@ resource "coder_script" "filebrowser" { LOG_PATH : var.log_path, DB_PATH : var.database_path, SUBDOMAIN : var.subdomain, - SERVER_BASE_PATH : format("/@%s/%s.%s/apps/vscode-web/", + SERVER_BASE_PATH : format("/@%s/%s.%s/apps/filebrowser", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name), }) run_on_start = true From edb7182f1d0ebe3f204ee3091dc6a3faebd621ed Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:58:37 +0200 Subject: [PATCH 11/21] update sudomain=false example --- filebrowser/README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index e3a3d22f..65fc5c15 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -47,13 +47,11 @@ module "filebrowser" { ### Serve from the same domain (no subdomain) -Make sure to set both workspace_name and owner_name. - ```tf module "filebrowser" { - source = "registry.coder.com/modules/filebrowser/coder" - agent_id = coder_agent.main.id - workspace_name = data.coder_workspace.me.name - owner_name = data.coder_workspace_owner.me.name + source = "registry.coder.com/modules/filebrowser/coder" + agent_id = coder_agent.main.id + subdomain = false + agent_name = "main" } ``` \ No newline at end of file From 1f2c0b616e65d6fa0a7bd8e703db45c63ea53825 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:12:27 +0200 Subject: [PATCH 12/21] move all subpath build logic to terraform --- filebrowser/main.tf | 3 +-- filebrowser/run.sh | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 2e737566..fe5cc5b2 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -83,8 +83,7 @@ resource "coder_script" "filebrowser" { LOG_PATH : var.log_path, DB_PATH : var.database_path, SUBDOMAIN : var.subdomain, - SERVER_BASE_PATH : format("/@%s/%s.%s/apps/filebrowser", - data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name), + SERVER_BASE_PATH : var.subdomain ? "" : format("/@%s/%s.%s/apps/filebrowser", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name), }) run_on_start = true } diff --git a/filebrowser/run.sh b/filebrowser/run.sh index ef94ffb8..22f13ed1 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -17,12 +17,8 @@ if [ "${DB_PATH}" != "filebrowser.db" ]; then DB_FLAG=" -d ${DB_PATH}" fi -# set baseurl if subdomain = false -if [ "${SUBDOMAIN}" == "false" ]; then - filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1 -else - filebrowser config set --baseurl "" > ${LOG_PATH} 2>&1 -fi +# set baseurl to be able to run if sudomain=false; if subdomain=true the SERVER_BASE_PATH value will be "" +filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1 printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n" From e10903c1f1559367d96a16e2ec55558ad2e20fc5 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:45:51 +0200 Subject: [PATCH 13/21] Add subdomain variable Add missing subdomain variable --- filebrowser/main.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index fe5cc5b2..023b5f41 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -72,6 +72,15 @@ variable "order" { default = null } +variable "subdomain" { + type = bool + description = <<-EOT + Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. + If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible. + EOT + default = true +} + resource "coder_script" "filebrowser" { agent_id = var.agent_id display_name = "File Browser" From 6a28f52a2c131c51e08f343652ef59b0320ad673 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 17 Sep 2024 10:07:26 +0200 Subject: [PATCH 14/21] Fix data fields, Add test - Fix subdomain variable expected as number by count in data fields - Add test case for subdomain=false --- filebrowser/main.test.ts | 22 ++++++++++++++++++++++ filebrowser/main.tf | 8 ++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts index 79dd99d0..311498c8 100644 --- a/filebrowser/main.test.ts +++ b/filebrowser/main.test.ts @@ -88,4 +88,26 @@ describe("filebrowser", async () => { "📝 Logs at /tmp/filebrowser.log", ]); }); + + it("runs with subdomain=false", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + subdomain: false, + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(0); + expect(output.stdout).toEqual([ + "\u001B[0;1mInstalling filebrowser ", + "", + "🥳 Installation complete! ", + "", + "👷 Starting filebrowser in background... ", + "", + "📂 Serving /root at http://localhost:13339 ", + "", + "Running 'filebrowser --noauth --root /root --port 13339' ", + "", + "📝 Logs at /tmp/filebrowser.log", + ]); + }); }); diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 023b5f41..8aafd7a6 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -14,13 +14,9 @@ variable "agent_id" { description = "The ID of a Coder agent." } -data "coder_workspace" "me" { - count = var.subdomain -} +data "coder_workspace" "me" {} -data "coder_workspace_owner" "me" { - count = var.subdomain -} +data "coder_workspace_owner" "me" {} variable "agent_name" { type = string From 9e3dcc9399678e16c5106a4c10ebf95a4042c554 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:41:14 +0200 Subject: [PATCH 15/21] Fix filebrowser redirect to subpath on start --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 8aafd7a6..dfea0914 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -97,7 +97,7 @@ resource "coder_app" "filebrowser" { agent_id = var.agent_id slug = "filebrowser" display_name = "File Browser" - url = "http://localhost:${var.port}" + url = "http://localhost:${var.port}/files" icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" subdomain = var.subdomain share = var.share From a78e65abe1caa217b599d625b5fb3a85d1618f3a Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:43:47 +0200 Subject: [PATCH 16/21] Fix filebrowser redirect to subpath on start --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index dfea0914..3c33e251 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -97,7 +97,7 @@ resource "coder_app" "filebrowser" { agent_id = var.agent_id slug = "filebrowser" display_name = "File Browser" - url = "http://localhost:${var.port}/files" + url = "http://localhost:${var.port}/" icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" subdomain = var.subdomain share = var.share From df99df6fe01795c1c647d97c5b16ad7e6aa5c08d Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:46:11 +0200 Subject: [PATCH 17/21] Revert: Fix filebrowser redirect to subpath on start --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 3c33e251..8aafd7a6 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -97,7 +97,7 @@ resource "coder_app" "filebrowser" { agent_id = var.agent_id slug = "filebrowser" display_name = "File Browser" - url = "http://localhost:${var.port}/" + url = "http://localhost:${var.port}" icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg" subdomain = var.subdomain share = var.share From f234fc4dc673364d125afdddd3a0ef6ec4037de0 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:50:27 +0200 Subject: [PATCH 18/21] Set default agent_name to "main" --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 8aafd7a6..b6d4ff5d 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -20,7 +20,7 @@ data "coder_workspace_owner" "me" {} variable "agent_name" { type = string - default = "" + default = "main" description = "The name of the main deployment. (Used to build the subpath for coder_app.)" } From 2659fc306bae44e8d31ccdd17c60ba8e1e7b2a08 Mon Sep 17 00:00:00 2001 From: Seppdo <85109829+Seppdo@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:20:06 +0200 Subject: [PATCH 19/21] Make agent_name required parameter Co-authored-by: Muhammad Atif Ali --- filebrowser/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index b6d4ff5d..64031c14 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -20,7 +20,6 @@ data "coder_workspace_owner" "me" {} variable "agent_name" { type = string - default = "main" description = "The name of the main deployment. (Used to build the subpath for coder_app.)" } From 8f8eb6370f0469e3eff51c89476edf1f5305d7f7 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 18 Sep 2024 10:09:03 +0200 Subject: [PATCH 20/21] Add agent_name to test cases - Add agent_name to test cases since it is a required variable (even on those cases where it is not actually needed) - Prettify README.md --- filebrowser/README.md | 23 +++++++++++++---------- filebrowser/main.test.ts | 6 ++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index 65fc5c15..50b503ab 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -13,9 +13,10 @@ A file browser for your workspace. ```tf module "filebrowser" { - source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.8" - agent_id = coder_agent.example.id + source = "registry.coder.com/modules/filebrowser/coder" + version = "1.0.8" + agent_id = coder_agent.example.id + agent_name = "main" } ``` @@ -27,10 +28,11 @@ module "filebrowser" { ```tf module "filebrowser" { - source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.8" - agent_id = coder_agent.example.id - folder = "/home/coder/project" + source = "registry.coder.com/modules/filebrowser/coder" + version = "1.0.8" + agent_id = coder_agent.example.id + agent_name = "main" + folder = "/home/coder/project" } ``` @@ -41,6 +43,7 @@ module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" version = "1.0.8" agent_id = coder_agent.example.id + agent_name = "main" database_path = ".config/filebrowser.db" } ``` @@ -50,8 +53,8 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - agent_id = coder_agent.main.id - subdomain = false + agent_id = coder_agent.example.id agent_name = "main" + subdomain = false } -``` \ No newline at end of file +``` diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts index 311498c8..ff6d045e 100644 --- a/filebrowser/main.test.ts +++ b/filebrowser/main.test.ts @@ -11,11 +11,13 @@ describe("filebrowser", async () => { testRequiredVariables(import.meta.dir, { agent_id: "foo", + agent_name: "main", }); it("fails with wrong database_path", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + agent_name: "main", database_path: "nofb", }).catch((e) => { if (!e.message.startsWith("\nError: Invalid value for variable")) { @@ -27,6 +29,7 @@ describe("filebrowser", async () => { it("runs with default", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + agent_name: "main", }); const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(0); @@ -48,6 +51,7 @@ describe("filebrowser", async () => { it("runs with database_path var", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + agent_name: "main", database_path: ".config/filebrowser.db", }); const output = await executeScriptInContainer(state, "alpine"); @@ -70,6 +74,7 @@ describe("filebrowser", async () => { it("runs with folder var", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + agent_name: "main", folder: "/home/coder/project", }); const output = await executeScriptInContainer(state, "alpine"); @@ -92,6 +97,7 @@ describe("filebrowser", async () => { it("runs with subdomain=false", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", + agent_name: "main", subdomain: false, }); const output = await executeScriptInContainer(state, "alpine"); From f3a27eef1740db1e15e65e204e55486e4b787ebc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 18 Sep 2024 10:26:29 +0200 Subject: [PATCH 21/21] run: bin i && bun fmt --- filebrowser/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebrowser/main.tf b/filebrowser/main.tf index 64031c14..e6b88c61 100644 --- a/filebrowser/main.tf +++ b/filebrowser/main.tf @@ -19,7 +19,7 @@ data "coder_workspace" "me" {} data "coder_workspace_owner" "me" {} variable "agent_name" { - type = string + type = string description = "The name of the main deployment. (Used to build the subpath for coder_app.)" }