Skip to content

Commit 3f72edb

Browse files
committed
feat(vscode-web): add platform settings option
1 parent 31b8312 commit 3f72edb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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)