Skip to content

Commit 8bf1789

Browse files
blinkagent[bot]blink-so[bot]DevelopmentCats
authored
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 <christofer@coder.com>
1 parent 9e89f04 commit 8bf1789

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

registry/coder/modules/code-server/README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w
1414
module "code-server" {
1515
count = data.coder_workspace.me.start_count
1616
source = "registry.coder.com/coder/code-server/coder"
17-
version = "1.3.1"
17+
version = "1.4.0"
1818
agent_id = coder_agent.example.id
1919
}
2020
```
@@ -29,7 +29,7 @@ module "code-server" {
2929
module "code-server" {
3030
count = data.coder_workspace.me.start_count
3131
source = "registry.coder.com/coder/code-server/coder"
32-
version = "1.3.1"
32+
version = "1.4.0"
3333
agent_id = coder_agent.example.id
3434
install_version = "4.8.3"
3535
}
@@ -43,7 +43,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
4343
module "code-server" {
4444
count = data.coder_workspace.me.start_count
4545
source = "registry.coder.com/coder/code-server/coder"
46-
version = "1.3.1"
46+
version = "1.4.0"
4747
agent_id = coder_agent.example.id
4848
extensions = [
4949
"dracula-theme.theme-dracula"
@@ -61,7 +61,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
6161
module "code-server" {
6262
count = data.coder_workspace.me.start_count
6363
source = "registry.coder.com/coder/code-server/coder"
64-
version = "1.3.1"
64+
version = "1.4.0"
6565
agent_id = coder_agent.example.id
6666
extensions = ["dracula-theme.theme-dracula"]
6767
settings = {
@@ -78,12 +78,26 @@ Just run code-server in the background, don't fetch it from GitHub:
7878
module "code-server" {
7979
count = data.coder_workspace.me.start_count
8080
source = "registry.coder.com/coder/code-server/coder"
81-
version = "1.3.1"
81+
version = "1.4.0"
8282
agent_id = coder_agent.example.id
8383
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
8484
}
8585
```
8686

87+
### Pass Additional Arguments
88+
89+
You can pass additional command-line arguments to code-server using the `additional_args` variable. For example, to disable workspace trust:
90+
91+
```tf
92+
module "code-server" {
93+
count = data.coder_workspace.me.start_count
94+
source = "registry.coder.com/coder/code-server/coder"
95+
version = "1.4.0"
96+
agent_id = coder_agent.example.id
97+
additional_args = "--disable-workspace-trust"
98+
}
99+
```
100+
87101
### Offline and Use Cached Modes
88102

89103
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:
94108
module "code-server" {
95109
count = data.coder_workspace.me.start_count
96110
source = "registry.coder.com/coder/code-server/coder"
97-
version = "1.3.1"
111+
version = "1.4.0"
98112
agent_id = coder_agent.example.id
99113
use_cached = true
100114
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:
107121
module "code-server" {
108122
count = data.coder_workspace.me.start_count
109123
source = "registry.coder.com/coder/code-server/coder"
110-
version = "1.3.1"
124+
version = "1.4.0"
111125
agent_id = coder_agent.example.id
112126
offline = true
113127
}

registry/coder/modules/code-server/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ variable "open_in" {
148148
}
149149
}
150150

151+
variable "additional_args" {
152+
type = string
153+
description = "Additional command-line arguments to pass to code-server (e.g., '--disable-workspace-trust')."
154+
default = ""
155+
}
156+
151157
resource "coder_script" "code-server" {
152158
agent_id = var.agent_id
153159
display_name = "code-server"
@@ -168,6 +174,7 @@ resource "coder_script" "code-server" {
168174
EXTENSIONS_DIR : var.extensions_dir,
169175
FOLDER : var.folder,
170176
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
177+
ADDITIONAL_ARGS : var.additional_args,
171178
})
172179
run_on_start = true
173180

registry/coder/modules/code-server/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616
function run_code_server() {
1717
echo "👷 Running code-server in the background..."
1818
echo "Check logs at ${LOG_PATH}!"
19-
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" > "${LOG_PATH}" 2>&1 &
19+
$CODE_SERVER "$EXTENSION_ARG" --auth none --port "${PORT}" --app-name "${APP_NAME}" ${ADDITIONAL_ARGS} > "${LOG_PATH}" 2>&1 &
2020
}
2121

2222
# Check if the settings file exists...

0 commit comments

Comments
 (0)