Compare commits

...

6 Commits

Author SHA1 Message Date
Muhammad Atif Ali 271c0bf6c1 Bump JetBrains Gateway module version to 1.0.24 11 months ago
Muhammad Atif Ali 734f4a7009 Improve JetBrains IDE parameter naming 11 months ago
Muhammad Atif Ali b57d7f170c Refine display logic for JetBrains IDE keys 11 months ago
Muhammad Atif Ali 630a92966c Refactor JetBrains output to use local variables 11 months ago
Muhammad Atif Ali 309c7eb24b Improve slug format in JetBrains Gateway module 11 months ago
Muhammad Atif Ali ef10dcfc67 Support multiple default IDEs in JetBrains Gateway
Refactor the `default` variable to accept a list, enabling the
specification of multiple default IDEs. This change allows users
to manage configurations for multiple IDEs more efficiently.

- Updated `default` type from string to list(string)
- Iterated over default IDEs to generate corresponding resources
- Ensured backward compatibility where single IDE configs were used
11 months ago

@ -14,12 +14,12 @@ 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.23"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["CL", "GO", "IU", "PY", "WS"]
default = "GO"
default = ["GO"]
}
```
@ -32,12 +32,12 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.23"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["GO", "WS"]
default = "GO"
default = ["GO"]
}
```
@ -46,12 +46,12 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.23"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["GO", "WS"]
default = "GO"
default = ["GO"]
latest = true
}
```
@ -61,32 +61,46 @@ module "jetbrains_gateway" {
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.23"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["GO", "WS"]
default = "GO"
default = ["GO"]
latest = true
channel = "eap"
}
```
### Custom base link
### Add Multiple IDEs with the default set to GoLand
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["GO", "WS", "RD", "PY"]
default = ["GO", "PY"]
}
```
### Custom release download link
Due to the highest priority of the `ide_download_link` parameter in the `(jetbrains-gateway://...` within IDEA, the pre-configured download address will be overridden when using [IDEA's offline mode](https://www.jetbrains.com/help/idea/fully-offline-mode.html). Therefore, it is necessary to configure the `download_base_link` parameter for the `jetbrains_gateway` module to change the value of `ide_download_link`.
```tf
module "jetbrains_gateway" {
source = "registry.coder.com/modules/jetbrains-gateway/coder"
version = "1.0.23"
version = "1.0.24"
agent_id = coder_agent.example.id
agent_name = "example"
folder = "/home/coder/example"
jetbrains_ides = ["GO", "WS"]
releases_base_link = "https://releases.internal.site/"
download_base_link = "https://download.internal.site/"
default = "GO"
default = ["GO"]
}
```

@ -20,7 +20,7 @@ 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"
default = "gateway"
}
@ -39,9 +39,9 @@ variable "folder" {
}
variable "default" {
default = ""
type = string
description = "Default IDE"
default = []
type = list(string)
description = "Default IDEs to be added to the Workspace page."
}
variable "order" {
@ -166,6 +166,12 @@ variable "download_base_link" {
}
}
variable "provide_options" {
type = bool
description = "Whether to provide coder_parameter options."
default = true
}
data "http" "jetbrains_ide_versions" {
for_each = var.latest ? toset(var.jetbrains_ides) : toset([])
url = "${var.releases_base_link}/products/releases?code=${each.key}&latest=true&type=${var.channel}"
@ -239,23 +245,19 @@ locals {
}
}
icon = local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].icon
json_data = var.latest ? jsondecode(data.http.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].response_body) : {}
key = var.latest ? keys(local.json_data)[0] : ""
display_name = local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].name
identifier = data.coder_parameter.jetbrains_ide.value
download_link = var.latest ? local.json_data[local.key][0].downloads.linux.link : local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].download_link
build_number = var.latest ? local.json_data[local.key][0].build : local.jetbrains_ides[data.coder_parameter.jetbrains_ide.value].build_number
version = var.latest ? local.json_data[local.key][0].version : var.jetbrains_ide_versions[data.coder_parameter.jetbrains_ide.value].version
default_ide_map = {
for ide in var.default : ide => local.jetbrains_ides[ide]
}
}
data "coder_parameter" "jetbrains_ide" {
for_each = local.default_ide_map
type = "string"
name = "jetbrains_ide"
display_name = "JetBrains IDE"
name = "jetbrains_ide_${each.key}"
display_name = "JetBrains IDE ${each.key}"
icon = "/icon/gateway.svg"
mutable = true
default = var.default == "" ? var.jetbrains_ides[0] : var.default
default = each.key
order = var.coder_parameter_order
dynamic "option" {
@ -272,10 +274,11 @@ data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}
resource "coder_app" "gateway" {
for_each = local.default_ide_map
agent_id = var.agent_id
slug = var.slug
display_name = local.display_name
icon = local.icon
slug = "${var.slug}-${lower(each.key)}"
display_name = each.value.name
icon = each.value.icon
external = true
order = var.order
url = join("", [
@ -292,38 +295,23 @@ resource "coder_app" "gateway" {
"&token=",
"$SESSION_TOKEN",
"&ide_product_code=",
data.coder_parameter.jetbrains_ide.value,
each.key,
"&ide_build_number=",
local.build_number,
each.value.build_number,
"&ide_download_link=",
local.download_link,
each.value.download_link,
])
}
output "identifier" {
value = local.identifier
}
output "display_name" {
value = local.display_name
}
output "icon" {
value = local.icon
}
output "download_link" {
value = local.download_link
}
output "build_number" {
value = local.build_number
}
output "version" {
value = local.version
}
output "url" {
value = coder_app.gateway.url
output "coder_apps" {
value = {
for key, app in coder_app.gateway : key => {
identifier = key
display_name = app.display_name
icon = local.jetbrains_ides[key].icon
download_link = local.jetbrains_ides[key].download_link
build_number = local.jetbrains_ides[key].build_number
version = local.jetbrains_ides[key].version
}
}
}

Loading…
Cancel
Save