Compare commits

...

4 Commits

Author SHA1 Message Date
Muhammad Atif Ali 8122e3a3fb Update server_base_path format logic in modules
This change addresses the improvement of readability and consistency by simplifying the `server_base_path` construction logic, thereby enhancing maintainability across the respective Terraform modules.
8 months ago
Muhammad Atif Ali 01a25f7182 Refactor devolutions-patch.js for reduced indent size
Refactor the `windows-rdp/devolutions-patch.js` script to use a two-space
indentation style from a previous four-space style. This change improves
code readability and consistency with the project's codebase formatting
style.

All functional code remains unaffected; only formatting has been
adjusted.
8 months ago
Muhammad Atif Ali 5e02fd8056 Add data sources to Jupyter Notebook module
Enables dynamic retrieval of workspace owner and details, improving
flexibility and accuracy in referencing coder workspace information.
8 months ago
Muhammad Atif Ali 0b2bc1de9e Refactor multiple modules for improved flexibility
- Transition modules to use slug and agent_name variables for custom configurations.
- Update Terraform resources to dynamically generate URLs and paths.
- Enhance form handling logic in Devolutions patch script.
8 months ago

@ -14,7 +14,7 @@ A file browser for your workspace.
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
}
```
@ -28,7 +28,7 @@ module "filebrowser" {
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
folder = "/home/coder/project"
}
@ -39,17 +39,29 @@ module "filebrowser" {
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
database_path = ".config/filebrowser.db"
}
```
### Serve from the same domain (no subdomain)
### Serve on a subpath (no wildcard subdomain)
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
subdomain = false
}
```
### Serve on a subpath with a specific agent name (multiple agents)
```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "main"
subdomain = false

@ -20,13 +20,8 @@ data "coder_workspace_owner" "me" {}
variable "agent_name" {
type = string
description = "The name of the main deployment. (Used to build the subpath for coder_app.)"
default = ""
validation {
# If subdomain is false, then agent_name must be set.
condition = var.subdomain || var.agent_name != ""
error_message = "The agent_name must be set."
}
description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
default = null
}
variable "database_path" {
@ -73,6 +68,12 @@ variable "order" {
default = null
}
variable "slug" {
type = string
description = "The slug of the coder_app resource."
default = "filebrowser"
}
variable "subdomain" {
type = bool
description = <<-EOT
@ -85,7 +86,7 @@ variable "subdomain" {
resource "coder_script" "filebrowser" {
agent_id = var.agent_id
display_name = "File Browser"
icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
icon = "/icon/filebrowser.svg"
script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path,
PORT : var.port,
@ -93,18 +94,30 @@ resource "coder_script" "filebrowser" {
LOG_PATH : var.log_path,
DB_PATH : var.database_path,
SUBDOMAIN : var.subdomain,
SERVER_BASE_PATH : var.subdomain ? "" : format("/@%s/%s.%s/apps/filebrowser", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name),
SERVER_BASE_PATH : local.server_base_path
})
run_on_start = true
}
resource "coder_app" "filebrowser" {
agent_id = var.agent_id
slug = "filebrowser"
slug = var.slug
display_name = "File Browser"
url = "http://localhost:${var.port}"
icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
url = local.url
icon = "/icon/filebrowser.svg"
subdomain = var.subdomain
share = var.share
order = var.order
healthcheck {
url = local.healthcheck_url
interval = 5
threshold = 6
}
}
locals {
server_base_path = var.subdomain ? "" : format("/@%s/%s%s/apps/%s", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name != null ? ".${var.agent_name}" : "", var.slug)
url = "http://localhost:${var.port}${local.server_base_path}"
healthcheck_url = "http://localhost:${var.port}${local.server_base_path}/health"
}

@ -14,7 +14,7 @@ This module adds a JetBrains Gateway Button to open any workspace with a single
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.21"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
@ -32,7 +32,7 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.21"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
@ -46,7 +46,7 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.21"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
@ -61,7 +61,7 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.21"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"

@ -20,13 +20,13 @@ variable "agent_id" {
variable "slug" {
type = string
description = "The slug for the coder_app. Allows resuing the module with the same template."
description = "The slug for the coder_app resource."
default = "gateway"
}
variable "agent_name" {
type = string
description = "Agent name."
description = "The name of the coder_agent resource."
}
variable "folder" {
@ -258,26 +258,18 @@ resource "coder_app" "gateway" {
icon = local.icon
external = true
order = var.order
url = join("", [
"jetbrains-gateway://connect#type=coder&workspace=",
url = format(
"jetbrains-gateway://connect#type=coder&workspace=%s&owner=%s&agent=%s&folder=%s&url=%s&token=%s&ide_product_code=%s&ide_build_number=%s&ide_download_link=%s",
data.coder_workspace.me.name,
"&owner=",
data.coder_workspace_owner.me.name,
"&agent=",
var.agent_name,
"&folder=",
var.folder,
"&url=",
data.coder_workspace.me.access_url,
"&token=",
"$SESSION_TOKEN",
"&ide_product_code=",
data.coder_parameter.jetbrains_ide.value,
"&ide_build_number=",
local.build_number,
"&ide_download_link=",
local.download_link,
])
local.download_link
)
}
output "identifier" {

@ -11,12 +11,36 @@ tags: [jupyter, helper, ide, web]
A module that adds Jupyter Notebook in your Coder template.
```tf
module "jupyter-notebook" {
source = "registry.coder.com/modules/jupyter-notebook/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
}
```
![Jupyter Notebook](../.images/jupyter-notebook.png)
## Examples
### Serve on a subpath (no wildcard subdomain)
```tf
module "jupyter-notebook" {
source = "registry.coder.com/modules/jupyter-notebook/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
subdomain = false
}
```
### Serve on a subpath with a specific agent name (multiple agents)
```tf
module "jupyter-notebook" {
source = "registry.coder.com/modules/jupyter-notebook/coder"
version = "1.0.19"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "main"
}
```

@ -42,9 +42,30 @@ variable "order" {
default = null
}
variable "agent_name" {
type = string
description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
default = null
}
variable "slug" {
type = string
description = "The slug of the coder_app resource."
default = "jupyter-notebook"
}
variable "subdomain" {
type = bool
description = <<-EOT
Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder.
If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible.
EOT
default = true
}
resource "coder_script" "jupyter-notebook" {
agent_id = var.agent_id
display_name = "jupyter-notebook"
display_name = "Jupyter Notebook"
icon = "/icon/jupyter.svg"
script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path,
@ -55,11 +76,26 @@ resource "coder_script" "jupyter-notebook" {
resource "coder_app" "jupyter-notebook" {
agent_id = var.agent_id
slug = "jupyter-notebook"
slug = var.slug
display_name = "Jupyter Notebook"
url = "http://localhost:${var.port}"
url = local.url
icon = "/icon/jupyter.svg"
subdomain = true
share = var.share
order = var.order
healthcheck {
url = local.healthcheck_url
interval = 5
threshold = 6
}
}
data "coder_workspace_owner" "me" {}
data "coder_workspace" "me" {}
locals {
server_base_path = var.subdomain ? "" : format("/@%s/%s%s/apps/%s", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name != null ? ".${var.agent_name}" : "", var.slug)
url = "http://localhost:${var.port}${local.server_base_path}"
healthcheck_url = "http://localhost:${var.port}${local.server_base_path}/api"
}

@ -11,12 +11,36 @@ tags: [jupyter, helper, ide, web]
A module that adds JupyterLab in your Coder template.
```tf
module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
}
```
![JupyterLab](../.images/jupyterlab.png)
## Examples
### Serve on a subpath (no wildcard subdomain)
```tf
module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
subdomain = false
}
```
### Serve on a subpath with a specific agent name (multiple agents)
```tf
module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "main"
}
```

@ -41,7 +41,10 @@ variable "share" {
variable "subdomain" {
type = bool
description = "Determines whether JupyterLab will be accessed via its own subdomain or whether it will be accessed via a path on Coder."
description = <<-EOT
Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder.
If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible.
EOT
default = true
}
@ -51,6 +54,18 @@ variable "order" {
default = null
}
variable "agent_name" {
type = string
description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
default = null
}
variable "slug" {
type = string
description = "The slug of the coder_app resource."
default = "jupyterlab"
}
resource "coder_script" "jupyterlab" {
agent_id = var.agent_id
display_name = "jupyterlab"
@ -58,18 +73,24 @@ resource "coder_script" "jupyterlab" {
script = templatefile("${path.module}/run.sh", {
LOG_PATH : var.log_path,
PORT : var.port
BASE_URL : var.subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab"
BASE_URL : local.server_base_path
})
run_on_start = true
}
resource "coder_app" "jupyterlab" {
agent_id = var.agent_id
slug = "jupyterlab" # sync with the usage in URL
slug = var.slug
display_name = "JupyterLab"
url = var.subdomain ? "http://localhost:${var.port}" : "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab"
url = local.url
icon = "/icon/jupyter.svg"
subdomain = var.subdomain
share = var.share
order = var.order
}
locals {
server_base_path = var.subdomain ? "" : format("/@%s/%s%s/apps/%s", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name != null ? ".${var.agent_name}" : "", var.slug)
url = "http://localhost:${var.port}${local.server_base_path}"
healthcheck_url = "http://localhost:${var.port}${local.server_base_path}/api"
}

@ -16,7 +16,7 @@ Uses the [Coder Remote VS Code Extension](https://github.com/coder/vscode-coder)
```tf
module "vscode" {
source = "registry.coder.com/modules/vscode-desktop/coder"
version = "1.0.15"
version = "1.0.23"
agent_id = coder_agent.example.id
}
```
@ -28,7 +28,7 @@ module "vscode" {
```tf
module "vscode" {
source = "registry.coder.com/modules/vscode-desktop/coder"
version = "1.0.15"
version = "1.0.23"
agent_id = coder_agent.example.id
folder = "/home/coder/project"
}

@ -20,6 +20,12 @@ variable "folder" {
default = ""
}
variable "slug" {
type = string
description = "The slug of the coder_app resource."
default = "vscode-desktop"
}
variable "open_recent" {
type = bool
description = "Open the most recent workspace or folder. Falls back to the folder if there is no recent workspace or folder to open."
@ -39,21 +45,17 @@ resource "coder_app" "vscode" {
agent_id = var.agent_id
external = true
icon = "/icon/code.svg"
slug = "vscode"
slug = var.slug
display_name = "VS Code Desktop"
order = var.order
url = join("", [
"vscode://coder.coder-remote/open",
"?owner=",
url = format(
"vscode://coder.coder-remote/open?owner=%s&workspace=%s%s%s&url=%s&token=$SESSION_TOKEN",
data.coder_workspace_owner.me.name,
"&workspace=",
data.coder_workspace.me.name,
var.folder != "" ? join("", ["&folder=", var.folder]) : "",
var.folder != "" ? "&folder=${var.folder}" : "",
var.open_recent ? "&openRecent" : "",
"&url=",
data.coder_workspace.me.access_url,
"&token=$SESSION_TOKEN",
])
data.coder_workspace.me.access_url
)
}
output "vscode_url" {

@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
accept_license = true
}
@ -29,7 +29,7 @@ module "vscode-web" {
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
install_prefix = "/home/coder/.vscode-web"
folder = "/home/coder"
@ -42,7 +42,7 @@ module "vscode-web" {
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
accept_license = true
@ -56,7 +56,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.22"
version = "1.0.23"
agent_id = coder_agent.example.id
extensions = ["dracula-theme.theme-dracula"]
settings = {
@ -65,3 +65,26 @@ module "vscode-web" {
accept_license = true
}
```
### Serve on a subpath (no wildcard subdomain)
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
subdomain = false
}
```
### Serve on a subpath with a specific agent name (multiple agents)
```tf
module "vscode-web" {
source = "registry.coder.com/modules/vscode-web/coder"
version = "1.0.23"
agent_id = coder_agent.example.id
agent_name = "main"
subdomain = false
}
```

@ -130,6 +130,12 @@ variable "subdomain" {
default = true
}
variable "agent_name" {
type = string
description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
default = null
}
data "coder_workspace_owner" "me" {}
data "coder_workspace" "me" {}
@ -185,7 +191,7 @@ 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)
server_base_path = var.subdomain ? "" : format("/@%s/%s%s/apps/%s", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.agent_name != null ? ".${var.agent_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"
healthcheck_url = "http://localhost:${var.port}${local.server_base_path}/healthz"
}

@ -15,7 +15,7 @@ Enable Remote Desktop + a web based client on Windows workspaces, powered by [de
# AWS example. See below for examples of using this module with other providers
module "windows_rdp" {
source = "registry.coder.com/modules/windows-rdp/coder"
version = "1.0.18"
version = "1.0.23"
count = data.coder_workspace.me.start_count
agent_id = resource.coder_agent.main.id
resource_id = resource.aws_instance.dev.id
@ -33,7 +33,7 @@ module "windows_rdp" {
```tf
module "windows_rdp" {
source = "registry.coder.com/modules/windows-rdp/coder"
version = "1.0.18"
version = "1.0.23"
count = data.coder_workspace.me.start_count
agent_id = resource.coder_agent.main.id
resource_id = resource.aws_instance.dev.id
@ -45,7 +45,7 @@ module "windows_rdp" {
```tf
module "windows_rdp" {
source = "registry.coder.com/modules/windows-rdp/coder"
version = "1.0.18"
version = "1.0.23"
count = data.coder_workspace.me.start_count
agent_id = resource.coder_agent.main.id
resource_id = resource.google_compute_instance.dev[0].id

@ -39,6 +39,18 @@ variable "admin_password" {
sensitive = true
}
variable "port" {
type = number
description = "The port to run the Devolutions Gateway on."
default = 7171
}
variable "slug" {
type = string
description = "The slug of the coder_app resource."
default = "web-rdp"
}
resource "coder_script" "windows-rdp" {
agent_id = var.agent_id
display_name = "windows-rdp"
@ -47,6 +59,7 @@ resource "coder_script" "windows-rdp" {
script = templatefile("${path.module}/powershell-installation-script.tftpl", {
admin_username = var.admin_username
admin_password = var.admin_password
port = var.port
# Wanted to have this be in the powershell template file, but Terraform
# doesn't allow recursive calls to the templatefile function. Have to feed
@ -63,14 +76,14 @@ resource "coder_script" "windows-rdp" {
resource "coder_app" "windows-rdp" {
agent_id = var.agent_id
share = var.share
slug = "web-rdp"
slug = var.slug
display_name = "Web RDP"
url = "http://localhost:7171"
url = "http://localhost:${var.port}"
icon = "/icon/desktop.svg"
subdomain = true
healthcheck {
url = "http://localhost:7171"
url = "http://localhost:${var.port}"
interval = 5
threshold = 15
}
@ -80,7 +93,7 @@ resource "coder_app" "rdp-docs" {
agent_id = var.agent_id
display_name = "Local RDP"
slug = "rdp-docs"
icon = "https://raw.githubusercontent.com/matifali/logos/main/windows.svg"
url = "https://coder.com/docs/ides/remote-desktops#rdp-desktop"
icon = "/icon/windows.svg"
url = "https://coder.com/docs/user-guides/workspace-access/remote-desktops#rdp-desktop"
external = true
}

@ -47,7 +47,7 @@ Install-DGatewayPackage
# Configure Devolutions Gateway
$Hostname = "localhost"
$HttpListener = New-DGatewayListener 'http://*:7171' 'http://*:7171'
$HttpListener = New-DGatewayListener "http://*:${port}" "http://*:${port}"
$WebApp = New-DGatewayWebAppConfig -Enabled $true -Authentication None
$ConfigParams = @{
Hostname = $Hostname

Loading…
Cancel
Save