From 602e4a6d84a3b94e47824ed7ca1816f792482a64 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 03:52:47 +0000 Subject: [PATCH] fix: simplify workspace/folder handling using template variable - Add WORKSPACE_ARG template variable to main.tf using coalesce() - Remove conditional logic from run.sh since precondition ensures only one is set - Much cleaner approach that leverages Terraform's template system properly --- registry/coder/modules/vscode-web/main.tf | 1 + registry/coder/modules/vscode-web/run.sh | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/registry/coder/modules/vscode-web/main.tf b/registry/coder/modules/vscode-web/main.tf index 3912fa9f..eafbc597 100644 --- a/registry/coder/modules/vscode-web/main.tf +++ b/registry/coder/modules/vscode-web/main.tf @@ -185,6 +185,7 @@ resource "coder_script" "vscode-web" { 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, diff --git a/registry/coder/modules/vscode-web/run.sh b/registry/coder/modules/vscode-web/run.sh index 6c24e844..ddfcfe2a 100644 --- a/registry/coder/modules/vscode-web/run.sh +++ b/registry/coder/modules/vscode-web/run.sh @@ -23,17 +23,9 @@ if [ "${DISABLE_TRUST}" = true ]; then fi run_vscode_web() { - # Determine what to pass as the workspace argument - WORKSPACE_ARG="" - if [ -n "$${WORKSPACE}" ]; then - WORKSPACE_ARG="$${WORKSPACE}" - elif [ -n "$${FOLDER}" ]; then - WORKSPACE_ARG="$${FOLDER}" - fi - - 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}" "$${WORKSPACE_ARG}" > "$${LOG_PATH}" 2>&1 & + 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}" "${WORKSPACE_ARG}" > "${LOG_PATH}" 2>&1 & } # Check if the settings file exists...