From 8bf17899965ffadacfb70231f2d7d67301d050cd Mon Sep 17 00:00:00 2001 From: "blinkagent[bot]" <237617714+blinkagent[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 07:43:16 -0600 Subject: [PATCH] feat: add additional_args variable to code-server module (#536) This PR adds an `extra_args` variable to the code-server module, allowing users to pass additional command-line arguments to code-server. ## Changes - Added `additional_args` variable to `main.tf` with a default empty string - Updated `run.sh` to include `${ADDITIONAL_ARGS}` in the code-server command - Added documentation and example usage in `README.md` ## Use Case This solves the issue where users want to disable the workspace trust prompt by passing `--disable-workspace-trust` to code-server. See the discussion in https://codercom.slack.com/archives/C09H8LRLG8K/p1762983278455979 ## Example Usage ```tf module "code-server" { source = "registry.coder.com/coder/code-server/coder" version = "1.3.1" agent_id = coder_agent.example.id additional_args = "--disable-workspace-trust" } ``` The `additional_args` variable can accept any additional command-line arguments that code-server supports. --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> Co-authored-by: DevelopmentCats --- registry/coder/modules/code-server/README.md | 28 +++++++++++++++----- registry/coder/modules/code-server/main.tf | 7 +++++ registry/coder/modules/code-server/run.sh | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/registry/coder/modules/code-server/README.md b/registry/coder/modules/code-server/README.md index 13fb7b72..b9ed6b72 100644 --- a/registry/coder/modules/code-server/README.md +++ b/registry/coder/modules/code-server/README.md @@ -14,7 +14,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id } ``` @@ -29,7 +29,7 @@ module "code-server" { module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id install_version = "4.8.3" } @@ -43,7 +43,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/): module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id extensions = [ "dracula-theme.theme-dracula" @@ -61,7 +61,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id extensions = ["dracula-theme.theme-dracula"] settings = { @@ -78,12 +78,26 @@ Just run code-server in the background, don't fetch it from GitHub: module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"] } ``` +### Pass Additional Arguments + +You can pass additional command-line arguments to code-server using the `additional_args` variable. For example, to disable workspace trust: + +```tf +module "code-server" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/code-server/coder" + version = "1.4.0" + agent_id = coder_agent.example.id + additional_args = "--disable-workspace-trust" +} +``` + ### Offline and Use Cached Modes By default the module looks for code-server at `/tmp/code-server` but this can be changed with `install_prefix`. @@ -94,7 +108,7 @@ Run an existing copy of code-server if found, otherwise download from GitHub: module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id use_cached = true extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"] @@ -107,7 +121,7 @@ Just run code-server in the background, don't fetch it from GitHub: module "code-server" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/code-server/coder" - version = "1.3.1" + version = "1.4.0" agent_id = coder_agent.example.id offline = true } diff --git a/registry/coder/modules/code-server/main.tf b/registry/coder/modules/code-server/main.tf index 650829f6..f5651353 100644 --- a/registry/coder/modules/code-server/main.tf +++ b/registry/coder/modules/code-server/main.tf @@ -148,6 +148,12 @@ variable "open_in" { } } +variable "additional_args" { + type = string + description = "Additional command-line arguments to pass to code-server (e.g., '--disable-workspace-trust')." + default = "" +} + resource "coder_script" "code-server" { agent_id = var.agent_id display_name = "code-server" @@ -168,6 +174,7 @@ resource "coder_script" "code-server" { EXTENSIONS_DIR : var.extensions_dir, FOLDER : var.folder, AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions, + ADDITIONAL_ARGS : var.additional_args, }) run_on_start = true diff --git a/registry/coder/modules/code-server/run.sh b/registry/coder/modules/code-server/run.sh index 73bcd689..55918fa4 100644 --- a/registry/coder/modules/code-server/run.sh +++ b/registry/coder/modules/code-server/run.sh @@ -16,7 +16,7 @@ fi function run_code_server() { echo "👷 Running code-server in the background..." echo "Check logs at ${LOG_PATH}!" - $CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 & + $CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" ${ADDITIONAL_ARGS} > "${LOG_PATH}" 2>&1 & } # Check if the settings file exists...