mirror of
https://github.com/coder/registry.git
synced 2026-06-03 04:58:15 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 602e4a6d84 | |||
| fef2c41480 | |||
| 56dbdd9a5e | |||
| 2da86abcb9 | |||
| 4d4584624e | |||
| ecb6e8f4bf | |||
| e737aa2a38 |
@@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
accept_license = true
|
||||
}
|
||||
@@ -30,7 +30,7 @@ module "vscode-web" {
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
install_prefix = "/home/coder/.vscode-web"
|
||||
folder = "/home/coder"
|
||||
@@ -38,13 +38,26 @@ module "vscode-web" {
|
||||
}
|
||||
```
|
||||
|
||||
### Open a VS Code workspace file
|
||||
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
workspace = "/home/coder/project.code-workspace"
|
||||
accept_license = true
|
||||
}
|
||||
```
|
||||
|
||||
### Install Extensions
|
||||
|
||||
```tf
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
|
||||
accept_license = true
|
||||
@@ -59,7 +72,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
extensions = ["dracula-theme.theme-dracula"]
|
||||
settings = {
|
||||
@@ -77,7 +90,7 @@ By default, this module installs the latest. To pin a specific version, retrieve
|
||||
module "vscode-web" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
source = "registry.coder.com/coder/vscode-web/coder"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
agent_id = coder_agent.example.id
|
||||
commit_id = "e54c774e0add60467559eb0d1e229c6452cf8447"
|
||||
accept_license = true
|
||||
|
||||
@@ -38,5 +38,17 @@ describe("vscode-web", async () => {
|
||||
expect(t).toThrow("Offline mode does not allow extensions to be installed");
|
||||
});
|
||||
|
||||
it("folder and workspace can not be used together", () => {
|
||||
const t = async () => {
|
||||
await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
accept_license: "true",
|
||||
folder: "/home/coder",
|
||||
workspace: "/home/coder/project.code-workspace",
|
||||
});
|
||||
};
|
||||
expect(t).toThrow("Cannot specify both 'folder' and 'workspace'. Please use only one.");
|
||||
});
|
||||
|
||||
// More tests depend on shebang refactors
|
||||
});
|
||||
});
|
||||
@@ -34,7 +34,13 @@ variable "slug" {
|
||||
|
||||
variable "folder" {
|
||||
type = string
|
||||
description = "The folder to open in vscode-web."
|
||||
description = "The folder to open in vscode-web. Cannot be used with 'workspace'."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "workspace" {
|
||||
type = string
|
||||
description = "Path to a .code-workspace file to open on startup. Cannot be used with 'folder'."
|
||||
default = ""
|
||||
}
|
||||
|
||||
@@ -178,6 +184,8 @@ resource "coder_script" "vscode-web" {
|
||||
DISABLE_TRUST : var.disable_trust,
|
||||
EXTENSIONS_DIR : var.extensions_dir,
|
||||
FOLDER : var.folder,
|
||||
WORKSPACE : var.workspace,
|
||||
WORKSPACE_ARG : coalesce(var.workspace, var.folder),
|
||||
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
|
||||
SERVER_BASE_PATH : local.server_base_path,
|
||||
COMMIT_ID : var.commit_id,
|
||||
@@ -186,6 +194,11 @@ resource "coder_script" "vscode-web" {
|
||||
run_on_start = true
|
||||
|
||||
lifecycle {
|
||||
precondition {
|
||||
condition = !(var.folder != "" && var.workspace != "")
|
||||
error_message = "Cannot specify both 'folder' and 'workspace'. Please use only one."
|
||||
}
|
||||
|
||||
precondition {
|
||||
condition = !var.offline || length(var.extensions) == 0
|
||||
error_message = "Offline mode does not allow extensions to be installed"
|
||||
@@ -218,6 +231,11 @@ resource "coder_app" "vscode-web" {
|
||||
|
||||
locals {
|
||||
server_base_path = var.subdomain ? "" : format("/@%s/%s/apps/%s/", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.slug)
|
||||
url = var.folder == "" ? "http://localhost:${var.port}${local.server_base_path}" : "http://localhost:${var.port}${local.server_base_path}?folder=${var.folder}"
|
||||
healthcheck_url = var.subdomain ? "http://localhost:${var.port}/healthz" : "http://localhost:${var.port}${local.server_base_path}/healthz"
|
||||
}
|
||||
|
||||
# Mutually exclusive: workspace takes precedence over folder
|
||||
query_param = var.workspace != "" ? "workspace=${urlencode(var.workspace)}" : (var.folder != "" ? "folder=${urlencode(var.folder)}" : "")
|
||||
|
||||
url = local.query_param != "" ? "http://localhost:${var.port}${local.server_base_path}?${local.query_param}" : "http://localhost:${var.port}${local.server_base_path}"
|
||||
|
||||
healthcheck_url = var.subdomain ? "http://localhost:${var.port}/healthz" : "http://localhost:${var.port}${local.server_base_path}/healthz"
|
||||
}
|
||||
@@ -23,9 +23,9 @@ if [ "${DISABLE_TRUST}" = true ]; then
|
||||
fi
|
||||
|
||||
run_vscode_web() {
|
||||
echo "👷 Running $VSCODE_WEB serve-local $EXTENSION_ARG $SERVER_BASE_PATH_ARG $DISABLE_TRUST_ARG --port ${PORT} --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
|
||||
echo "👷 Running $VSCODE_WEB serve-local with workspace: ${WORKSPACE_ARG}"
|
||||
echo "Check logs at ${LOG_PATH}!"
|
||||
"$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 &
|
||||
"$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" "${WORKSPACE_ARG}" > "${LOG_PATH}" 2>&1 &
|
||||
}
|
||||
|
||||
# Check if the settings file exists...
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user