Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions registry/coder/modules/jetbrains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ module "jetbrains" {
}
```

### Pre-install Plugins

Provide a list of JetBrains Marketplace plugin IDs to install automatically after
the RemoteDev server is available on the workspace.

```tf
module "jetbrains" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/jetbrains/coder"
version = "1.3.0"
agent_id = coder_agent.main.id
folder = "/home/coder/project"

plugins = [
"org.intellij.plugins.markdown",
"com.jetbrains.python",
]
}
```

> Note: Plugins are installed once the JetBrains RemoteDev server is present on
> the workspace (triggered after the first Toolbox/Gateway connection).

### Accessing the IDE Metadata

You can now reference the output `ide_metadata` as a map.
Expand Down
43 changes: 43 additions & 0 deletions registry/coder/modules/jetbrains/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ variable "options" {
}
}

variable "plugins" {
type = list(string)
description = "A list of JetBrains plugin IDs to install in the remote IDEs."
default = []
}

variable "releases_base_link" {
type = string
description = "URL of the JetBrains releases base link."
Expand Down Expand Up @@ -214,6 +220,7 @@ locals {

# Convert the parameter value to a set for for_each
selected_ides = length(var.default) == 0 ? toset(jsondecode(coalesce(data.coder_parameter.jetbrains_ides[0].value, "[]"))) : toset(var.default)
plugins_string = join(" ", var.plugins)
}

data "coder_parameter" "jetbrains_ides" {
Expand Down Expand Up @@ -241,6 +248,42 @@ data "coder_parameter" "jetbrains_ides" {
data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}

resource "coder_script" "jetbrains_plugins" {
count = data.coder_workspace.me.start_count
agent_id = var.agent_id
display_name = "JetBrains plugins"
icon = "/icon/jetbrains.svg"
script = <<-EOT
#!/usr/bin/env bash
set -euo pipefail

plugins="${local.plugins_string}"
if [ -z "$plugins" ]; then
echo "No JetBrains plugins configured."
exit 0
fi

remote_dev_root="${HOME}/.cache/JetBrains/RemoteDev/dist"
if [ ! -d "$remote_dev_root" ]; then
echo "JetBrains RemoteDev not installed yet. Connect once with Toolbox or Gateway to install the IDE."
exit 0
fi

mapfile -t servers < <(find "$remote_dev_root" -type f -path "*/bin/remote-dev-server.sh" 2>/dev/null)
if [ ${#servers[@]} -eq 0 ]; then
echo "RemoteDev server script not found yet."
exit 0
fi

for server in "${servers[@]}"; do
for plugin in $plugins; do
echo "Installing plugin ${plugin} via ${server}"
"${server}" installPlugins "${plugin}" || true
done
done
EOT
}

resource "coder_app" "jetbrains" {
for_each = local.selected_ides
agent_id = var.agent_id
Expand Down