From f257920f2637a2f72c39518770572de0cd82acfe Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 19 Sep 2023 09:01:36 +0000 Subject: [PATCH 1/3] add jetbrains-gateway-ides --- jetbrains-gateway/README.md | 33 +++++++++ jetbrains-gateway/main.tf | 129 ++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 jetbrains-gateway/README.md create mode 100644 jetbrains-gateway/main.tf diff --git a/jetbrains-gateway/README.md b/jetbrains-gateway/README.md new file mode 100644 index 0000000..a258026 --- /dev/null +++ b/jetbrains-gateway/README.md @@ -0,0 +1,33 @@ +# JetBrains Gateway (jetBrains-gateway) module + +This module adds a JetBrains Gateway IDEs to your Coder template. + +## How to use this module + +To use this module, add the following snippet to your template manifest: + +```hcl +module "jetbrains_gatway" { + source = "git::https://github.com/coder/testing-modules.git//jetbrains-gateway" + agent_id = coder_agent.main.id + agent_name = "main" + project_directory = "/home/coder" + gateway_ide_product_code = ["GO","WS"] # A list of JetBrains product codes use ["ALL"] for all products +} +``` + +## Supported IDEs + +The following JetBrains IDEs are supported: + +- GoLand (`GO`) +- WebStorm (`WS`) +- IntelliJ IDEA Ultimate (`IU`) +- IntelliJ IDEA Community (`IC`) +- PyCharm Professional (`PY`) +- PyCharm Community (`PC`) +- PhpStorm (`PS`) +- CLion (`CL`) +- RubyMine (`RM`) +- DataGrip (`DB`) +- Rider (`RD`) diff --git a/jetbrains-gateway/main.tf b/jetbrains-gateway/main.tf new file mode 100644 index 0000000..993ea41 --- /dev/null +++ b/jetbrains-gateway/main.tf @@ -0,0 +1,129 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 0.11" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "agent_name" { + type = string + description = "The name of a Coder agent." +} + +variable "project_directory" { + type = string + description = "The directory to open in the IDE. e.g. /home/coder/project" +} + +variable "gateway_ide_product_code" { + type = list(string) + description = "The list of IDE product codes, e.g. ['GO', 'WS'] or ['ALL']" + default = ["ALL"] + validation { + condition = ( + length(var.gateway_ide_product_code) == 1 && var.gateway_ide_product_code[0] == "ALL" || + alltrue([ + for code in var.gateway_ide_product_code : contains(["IU", "IC", "PS", "WS", "PY", "PC", "CL", "GO", "DB", "RD", "RM"], code) + ]) + ) + error_message = "The gateway_ide_product_code must be ['ALL'] or a list of valid product codes. https://plugins.jetbrains.com/docs/marketplace/product-codes.html" + } +} + +locals { + gateway_ides = { + "GO" = { + icon = "/icon/goland.svg", + name = "GoLand", + value = jsonencode(["GO", "232.9921.53", "https://download.jetbrains.com/go/goland-2023.2.2.tar.gz"]) + }, + "WS" = { + icon = "/icon/webstorm.svg", + name = "WebStorm", + value = jsonencode(["WS", "232.9921.42", "https://download.jetbrains.com/webstorm/WebStorm-2023.2.2.tar.gz"]) + }, + "IU" = { + icon = "/icon/intellij.svg", + name = "IntelliJ IDEA Ultimate", + value = jsonencode(["IU", "232.9921.47", "https://download.jetbrains.com/idea/ideaIU-2023.2.2.tar.gz"]) + }, + "IC" = { + icon = "/icon/intellij.svg", + name = "IntelliJ IDEA Community", + value = jsonencode(["IC", "232.9921.47", "https://download.jetbrains.com/idea/ideaIC-2023.2.2.tar.gz"]) + }, + "PY" = { + icon = "/icon/pycharm.svg", + name = "PyCharm Professional", + value = jsonencode(["PY", "232.9559.58", "https://download.jetbrains.com/python/pycharm-professional-2023.2.1.tar.gz"]) + }, + "PC" = { + icon = "/icon/pycharm.svg", + name = "PyCharm Community", + value = jsonencode(["PC", "232.9559.58", "https://download.jetbrains.com/python/pycharm-community-2023.2.1.tar.gz"]) + }, + "RD" = { + icon = "/icon/rider.svg", + name = "Rider", + value = jsonencode(["RD", "232.9559.61", "https://download.jetbrains.com/rider/JetBrains.Rider-2023.2.1.tar.gz"]) + } + "CL" = { + icon = "/icon/clion.svg", + name = "CLion", + value = jsonencode(["CL", "232.9921.42", "https://download.jetbrains.com/cpp/CLion-2023.2.2.tar.gz"]) + }, + "DB" = { + icon = "/icon/datagrip.svg", + name = "DataGrip", + value = jsonencode(["DB", "232.9559.28", "https://download.jetbrains.com/datagrip/datagrip-2023.2.1.tar.gz"]) + }, + "PS" = { + icon = "/icon/phpstorm.svg", + name = "PhpStorm", + value = jsonencode(["PS", "232.9559.64", "https://download.jetbrains.com/webide/PhpStorm-2023.2.1.tar.gz"]) + }, + "RM" = { + icon = "/icon/rubymine.svg", + name = "RubyMine", + value = jsonencode(["RM", "232.9921.48", "https://download.jetbrains.com/ruby/RubyMine-2023.2.2.tar.gz"]) + } + } +} + +data "coder_parameter" "jetbrains_ide" { + type = "list(string)" + name = "jetbrains_ide" + display_name = "JetBrains IDE" + icon = "/icon/gateway.svg" + mutable = true + default = local.gateway_ides["GO"].value + + dynamic "option" { + for_each = contains(var.gateway_ide_product_code, "ALL") ? local.gateway_ides : { for key, value in local.gateway_ides : key => value if contains(var.gateway_ide_product_code, key) } + content { + icon = option.value.icon + name = option.value.name + value = option.value.value + } + } +} + +data "coder_workspace" "me" {} + +resource "coder_app" "gateway" { + agent_id = var.agent_id + display_name = data.coder_parameter.jetbrains_ide.option[index(data.coder_parameter.jetbrains_ide.option.*.value, data.coder_parameter.jetbrains_ide.value)].name + slug = "gateway" + url = "jetbrains-gateway://connect#type=coder&workspace=${data.coder_workspace.me.name}&agent=${var.agent_name}&folder=${var.project_directory}&url=${data.coder_workspace.me.access_url}&token=${data.coder_workspace.me.owner_session_token}&ide_product_code=${jsondecode(data.coder_parameter.jetbrains_ide.value)[0]}&ide_build_number=${jsondecode(data.coder_parameter.jetbrains_ide.value)[1]}&ide_download_link=${jsondecode(data.coder_parameter.jetbrains_ide.value)[2]}" + icon = data.coder_parameter.jetbrains_ide.option[index(data.coder_parameter.jetbrains_ide.option.*.value, data.coder_parameter.jetbrains_ide.value)].icon + external = true +} From c7b4a3893ae637a5b5007629bf15034d06ae8b69 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 19 Sep 2023 09:06:58 +0000 Subject: [PATCH 2/3] update README --- README.md | 1 + jetbrains-gateway/README.md | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a97ec6e..2d05e70 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Enjoy official, community, and partner modules to extend your Coder workspace. - [code-server](https://registry.coder.com/modules/code-server): Run VS Code in the browser - [personalize](https://registry.coder.com/modules/personalize): Execute a user-specific script on start - [VS Code Desktop](https://registry.coder.com/modules/vscode-desktop): Display a button to launch VS Code desktop in the dashboard. +- [JetBrains Gateway](https://registry.coder.com/modules/jetbrains-gateway): Display a button to launch JetBrains Gateway IDEs in the dashboard. ## Registry diff --git a/jetbrains-gateway/README.md b/jetbrains-gateway/README.md index a258026..d230338 100644 --- a/jetbrains-gateway/README.md +++ b/jetbrains-gateway/README.md @@ -1,4 +1,11 @@ -# JetBrains Gateway (jetBrains-gateway) module +--- +display_name: JetBrains Gateway +description: Add a one-click button to launch JetBrains Gateway IDEs in the dashboard. +icon: ../icons/gateway.svg +maintainer_github: coder +verified: true +--- +# JetBrains Gateway This module adds a JetBrains Gateway IDEs to your Coder template. @@ -7,7 +14,7 @@ This module adds a JetBrains Gateway IDEs to your Coder template. To use this module, add the following snippet to your template manifest: ```hcl -module "jetbrains_gatway" { +module "jetbrains_gateway" { source = "git::https://github.com/coder/testing-modules.git//jetbrains-gateway" agent_id = coder_agent.main.id agent_name = "main" From d4c77fc688997867a21c7a5fab2ef5fa24ad6f61 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 19 Sep 2023 09:09:16 +0000 Subject: [PATCH 3/3] update tags --- jetbrains-gateway/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jetbrains-gateway/README.md b/jetbrains-gateway/README.md index d230338..670bca0 100644 --- a/jetbrains-gateway/README.md +++ b/jetbrains-gateway/README.md @@ -4,6 +4,7 @@ description: Add a one-click button to launch JetBrains Gateway IDEs in the dash icon: ../icons/gateway.svg maintainer_github: coder verified: true +tags: [ide, jetbrains, gateway, goland, webstorm, intellij, pycharm, phpstorm, clion, rubymine, datagrip, rider] --- # JetBrains Gateway