8000 feat(vscode-web): add platform settings option (#94) · coder/registry@04669ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 04669ec

Browse files
authored
feat(vscode-web): add platform settings option (#94)
1 parent 55c9829 commit 04669ec

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

registry/coder/modules/vscode-web/README.md

Lines changed: 5 additions & 5 deletions
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/coder/vscode-web/coder"
18-
version = "1.0.30"
18+
version = "1.1.0"
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/coder/vscode-web/coder"
34-
version = "1.0.30"
34+
version = "1.1.0"
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/coder/vscode-web/coder"
48-
version = "1.0.30"
48+
version = "1.1.0"
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/coder/vscode-web/coder"
63-
version = "1.0.30"
63+
version = "1.1.0"
6464
agent_id = coder_agent.example.id
6565
extensions = ["dracula-theme.theme-dracula"]
6666
settings = {
@@ -78,7 +78,7 @@ By default, this module installs the latest. To pin a specific version, retrieve
7878
module "vscode-web" {
7979
count = data.coder_workspace.me.start_count
8080
source = "registry.coder.com/coder/vscode-web/coder"
81-
version = "1.0.30"
81+
version = "1.1.0"
8282
agent_id = coder_agent.example.id
8383
commit_id = "e54c774e0add60467559eb0d1e229c6452cf8447"
8484
accept_license = true

registry/coder/modules/vscode-web/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ variable "subdomain" {
136136
default = true
137137
}
138138

139+
variable "platform" {
140+
type = string
141+
description = "The platform to use for the VS Code Web."
142+
default = ""
143+
validation {
144+
condition = var.platform == "" || var.platform == "linux" || var.platform == "darwin" || var.platform == "alpine" || var.platform == "win32"
145+
error_message = "Incorrect value. Please set either 'linux', 'darwin', or 'alpine' or 'win32'."
146+
}
147+
}
148+
139149
data "coder_workspace_owner" "me" {}
140150
data "coder_workspace" "me" {}
141151

@@ -158,6 +168,7 @@ resource "coder_script" "vscode-web" {
158168
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
159169
SERVER_BASE_PATH : local.server_base_path,
160170
COMMIT_ID : var.commit_id,
171+
PLATFORM : var.platform,
161172
})
162173
run_on_start = true
163174

registry/coder/modules/vscode-web/run.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,26 @@ case "$ARCH" in
5959
;;
6060
esac
6161

62+
# Detect the platform
63+
if [ -n "${PLATFORM}" ]; then
64+
DETECTED_PLATFORM="${PLATFORM}"
65+
elif [ -f /etc/alpine-release ] || grep -qi 'ID=alpine' /etc/os-release 2>/dev/null || command -v apk > /dev/null 2>&1; then
66+
DETECTED_PLATFORM="alpine"
67+
elif [ "$(uname -s)" = "Darwin" ]; then
68+
DETECTED_PLATFORM="darwin"
69+
else
70+
DETECTED_PLATFORM="linux"
71+
fi
72+
6273
# Check if a specific VS Code Web commit ID was provided
6374
if [ -n "${COMMIT_ID}" ]; then
6475
HASH="${COMMIT_ID}"
6576
else
66-
HASH=$(curl -fsSL https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2)
77+
HASH=$(curl -fsSL https://update.code.visualstudio.com/api/commits/stable/server-$DETECTED_PLATFORM-$ARCH-web | cut -d '"' -f 2)
6778
fi
6879
printf "$${BOLD}VS Code Web commit id version $HASH.\n"
6980

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)
81+
output=$(curl -fsSL "https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH/vscode-server-$DETECTED_PLATFORM-$ARCH-web.tar.gz" | tar -xz -C "${INSTALL_PREFIX}" --strip-components 1)
7182

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

0 commit comments

Comments
 (0)
0