Skip to content

Commit 189636c

Browse files
authored
feat(vscode-web): allow pinning vscode-web version to a specific commit ID (#405)
Adds support for specifying a commit ID to pin the vscode-web version in the module with added example in README.
1 parent 4d25315 commit 189636c

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

Diff for: vscode-web/README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
1515
module "vscode-web" {
1616
count = data.coder_workspace.me.start_count
1717
source = "registry.coder.com/modules/vscode-web/coder"
18-
version = "1.0.29"
18+
version = "1.0.30"
1919
agent_id = coder_agent.example.id
2020
accept_license = true
2121
}
@@ -31,7 +31,7 @@ module "vscode-web" {
3131
module "vscode-web" {
3232
count = data.coder_workspace.me.start_count
3333
source = "registry.coder.com/modules/vscode-web/coder"
34-
version = "1.0.29"
34+
version = "1.0.30"
3535
agent_id = coder_agent.example.id
3636
install_prefix = "/home/coder/.vscode-web"
3737
folder = "/home/coder"
@@ -45,7 +45,7 @@ module "vscode-web" {
4545
module "vscode-web" {
4646
count = data.coder_workspace.me.start_count
4747
source = "registry.coder.com/modules/vscode-web/coder"
48-
version = "1.0.29"
48+
version = "1.0.30"
4949
agent_id = coder_agent.example.id
5050
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
5151
accept_license = true
@@ -60,7 +60,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
6060
module "vscode-web" {
6161
count = data.coder_workspace.me.start_count
6262
source = "registry.coder.com/modules/vscode-web/coder"
63-
version = "1.0.29"
63+
version = "1.0.30"
6464
agent_id = coder_agent.example.id
6565
extensions = ["dracula-theme.theme-dracula"]
6666
settings = {
@@ -69,3 +69,18 @@ module "vscode-web" {
6969
accept_license = true
7070
}
7171
```
72+
73+
### Pin a specific VS Code Web version
74+
75+
By default, this module installs the latest. To pin a specific version, retrieve the commit ID from the [VS Code Update API](https://update.code.visualstudio.com/api/commits/stable/server-linux-x64-web) and verify its corresponding release on the [VS Code GitHub Releases](https://github.com/microsoft/vscode/releases).
76+
77+
```tf
78+
module "vscode-web" {
79+
count = data.coder_workspace.me.start_count
80+
source = "registry.coder.com/modules/vscode-web/coder"
81+
version = "1.0.30"
82+
agent_id = coder_agent.example.id
83+
commit_id = "e54c774e0add60467559eb0d1e229c6452cf8447"
84+
accept_license = true
85+
}
86+
```

Diff for: vscode-web/main.tf

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ variable "install_prefix" {
5959
default = "/tmp/vscode-web"
6060
}
6161

62+
variable "commit_id" {
63+
type = string
64+
description = "Specify the commit ID of the VS Code Web binary to pin to a specific version. If left empty, the latest stable version is used."
65+
default = ""
66+
}
67+
6268
variable "extensions" {
6369
type = list(string)
6470
description = "A list of extensions to install."
@@ -151,6 +157,7 @@ resource "coder_script" "vscode-web" {
151157
FOLDER : var.folder,
152158
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
153159
SERVER_BASE_PATH : local.server_base_path,
160+
COMMIT_ID : var.commit_id,
154161
})
155162
run_on_start = true
156163

Diff for: vscode-web/run.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ case "$ARCH" in
5959
;;
6060
esac
6161

62-
HASH=$(curl -fsSL https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2)
63-
output=$(curl -fsSL https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH/vscode-server-linux-$ARCH-web.tar.gz | tar -xz -C ${INSTALL_PREFIX} --strip-components 1)
62+
# Check if a specific VS Code Web commit ID was provided
63+
if [ -n "${COMMIT_ID}" ]; then
64+
HASH="${COMMIT_ID}"
65+
else
66+
HASH=$(curl -fsSL https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2)
67+
fi
68+
printf "$${BOLD}VS Code Web commit id version $HASH.\n"
69+
70+
output=$(curl -fsSL "https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH/vscode-server-linux-$ARCH-web.tar.gz" | tar -xz -C "${INSTALL_PREFIX}" --strip-components 1)
6471

6572
if [ $? -ne 0 ]; then
6673
echo "Failed to install Microsoft Visual Studio Code Server: $output"

0 commit comments

Comments
 (0)