Refactor URL handling in vscode-web module

- Consolidates URL and path logic using locals.
- Simplifies script syntax, improving maintainability.
pull/288/head
Muhammad Atif Ali 9 months ago
parent eb95ea41ab
commit aa3d9b8a7a

@ -150,8 +150,7 @@ resource "coder_script" "vscode-web" {
EXTENSIONS_DIR : var.extensions_dir,
FOLDER : var.folder,
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
SERVER_BASE_PATH : var.subdomain ? "" : format("/@%s/%s/apps/vscode-web/",
data.coder_workspace_owner.me.name, data.coder_workspace.me.name),
SERVER_BASE_PATH : local.server_base_path,
})
run_on_start = true
@ -172,16 +171,21 @@ resource "coder_app" "vscode-web" {
agent_id = var.agent_id
slug = var.slug
display_name = var.display_name
url = var.folder == "" ? "http://localhost:${var.port}" : "http://localhost:${var.port}?folder=${var.folder}"
url = local.url
icon = "/icon/code.svg"
subdomain = var.subdomain
share = var.share
order = var.order
healthcheck {
url = "http://localhost:${var.port}/healthz"
url = local.healthcheck_url
interval = 5
threshold = 6
}
}
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"
}

Loading…
Cancel
Save