Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat: add order variable to coder_app modules #177

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .sample/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ variable "mutable" {
description = "Whether the parameter is mutable."
default = true
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}
# Add other variables here


Expand All @@ -72,6 +78,7 @@ resource "coder_app" "MODULE_NAME" {
icon = local.icon_url
subdomain = false
share = "owner"
order = var.order

# Remove if the app does not have a healthcheck endpoint
healthcheck {
Expand Down
7 changes: 7 additions & 0 deletions code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ variable "share" {
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

resource "coder_script" "code-server" {
agent_id = var.agent_id
display_name = "code-server"
Expand All @@ -101,6 +107,7 @@ resource "coder_app" "code-server" {
icon = "/icon/code.svg"
subdomain = false
share = var.share
order = var.order

healthcheck {
url = "http://localhost:${var.port}/healthz"
Expand Down
7 changes: 7 additions & 0 deletions filebrowser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ variable "share" {
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

resource "coder_script" "filebrowser" {
agent_id = var.agent_id
display_name = "File Browser"
Expand All @@ -74,4 +80,5 @@ resource "coder_app" "filebrowser" {
icon = "https://raw.githubusercontent.com/filebrowser/logo/master/icon_raw.svg"
subdomain = true
share = var.share
order = var.order
}
9 changes: 8 additions & 1 deletion jetbrains-gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ variable "default" {
description = "Default IDE"
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

variable "jetbrains_ide_versions" {
type = map(object({
build_number = string
Expand Down Expand Up @@ -184,6 +190,7 @@ resource "coder_app" "gateway" {
display_name = try(lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).name, "JetBrains IDE")
icon = try(lookup(local.jetbrains_ides, data.coder_parameter.jetbrains_ide.value).icon, "/icon/gateway.svg")
external = true
order = var.order
url = join("", [
"jetbrains-gateway://connect#type=coder&workspace=",
data.coder_workspace.me.name,
Expand Down Expand Up @@ -230,4 +237,4 @@ output "version" {

output "url" {
value = coder_app.gateway.url
}
}
7 changes: 7 additions & 0 deletions jupyter-notebook/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ variable "share" {
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

resource "coder_script" "jupyter-notebook" {
agent_id = var.agent_id
display_name = "jupyter-notebook"
Expand All @@ -55,4 +61,5 @@ resource "coder_app" "jupyter-notebook" {
icon = "/icon/jupyter.svg"
subdomain = true
share = var.share
order = var.order
}
7 changes: 7 additions & 0 deletions jupyterlab/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ variable "share" {
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

resource "coder_script" "jupyterlab" {
agent_id = var.agent_id
display_name = "jupyterlab"
Expand All @@ -55,4 +61,5 @@ resource "coder_app" "jupyterlab" {
icon = "/icon/jupyter.svg"
subdomain = true
share = var.share
order = var.order
}
13 changes: 13 additions & 0 deletions vscode-desktop/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,18 @@ describe("vscode-desktop", async () => {
expect(state.outputs.vscode_url.value).toBe(
"vscode://coder.coder-remote/open?owner=default&workspace=default&token=$SESSION_TOKEN",
);

const resources: any = state.resources;
expect(resources[1].instances[0].attributes.order).toBeNull();
});

it("expect order to be set", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
order: "22",
});

const resources: any = state.resources;
expect(resources[1].instances[0].attributes.order).toBe(22);
});
});
7 changes: 7 additions & 0 deletions vscode-desktop/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ variable "folder" {
default = ""
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

data "coder_workspace" "me" {}

resource "coder_app" "vscode" {
Expand All @@ -28,6 +34,7 @@ resource "coder_app" "vscode" {
icon = "/icon/code.svg"
slug = "vscode"
display_name = "VS Code Desktop"
order = var.order
url = var.folder != "" ? join("", [
"vscode://coder.coder-remote/open?owner=",
data.coder_workspace.me.owner,
Expand Down
7 changes: 7 additions & 0 deletions vscode-web/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ variable "telemetry_level" {
}
}

variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}

resource "coder_script" "vscode-web" {
agent_id = var.agent_id
display_name = "VS Code Web"
Expand All @@ -107,6 +113,7 @@ resource "coder_app" "vscode-web" {
icon = "/icon/code.svg"
subdomain = true
share = var.share
order = var.order

healthcheck {
url = "http://localhost:${var.port}/healthz"
Expand Down