Skip to content

Commit af8b4f0

Browse files
authored
chore: fix for jetbrains gateway agent_id issue (#437)
## Description Fixes a regression added in #167 which implemented support for multiple agents by appending the agent id to the URI, however in a single agent environment it results in the agent id from the template apply (on upload to Coder from client) being injected, and when a workspace is later built using the template the agent id is no longer correct. Resolves the error `The workspace “<name>” does not have an agent with ID “<id>”` being thrown by Jetbrains Gateway app upon attempting to open a Jetbrains app from within a Coder workspace. When wishing to target a specific Coder Agent with the Jetbrains Gateway module one should use the `agent_name` variable in the module configuration to specify the desired agent name. This will append the agent name to the URI. ## Type of Change - [ ] New module - [x] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information **Path:** `registry/coder/modules/jetbrains-gateway` **New version:** `v1.2.4` **Breaking change:** [ ] Yes [x] No ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun run fmt`) - [x] Changes tested locally ## Related Issues Reported by customer on Zendesk ticket 4391
1 parent 2de6a57 commit af8b4f0

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

registry/coder/modules/jetbrains-gateway/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Consult the [JetBrains documentation](https://www.jetbrains.com/help/idea/prereq
1919
module "jetbrains_gateway" {
2020
count = data.coder_workspace.me.start_count
2121
source = "registry.coder.com/coder/jetbrains-gateway/coder"
22-
version = "1.2.3"
22+
version = "1.2.4"
2323
agent_id = coder_agent.example.id
2424
folder = "/home/coder/example"
2525
jetbrains_ides = ["CL", "GO", "IU", "PY", "WS"]
@@ -37,7 +37,7 @@ module "jetbrains_gateway" {
3737
module "jetbrains_gateway" {
3838
count = data.coder_workspace.me.start_count
3939
source = "registry.coder.com/coder/jetbrains-gateway/coder"
40-
version = "1.2.3"
40+
version = "1.2.4"
4141
agent_id = coder_agent.example.id
4242
folder = "/home/coder/example"
4343
jetbrains_ides = ["GO", "WS"]
@@ -51,7 +51,7 @@ module "jetbrains_gateway" {
5151
module "jetbrains_gateway" {
5252
count = data.coder_workspace.me.start_count
5353
source = "registry.coder.com/coder/jetbrains-gateway/coder"
54-
version = "1.2.3"
54+
version = "1.2.4"
5555
agent_id = coder_agent.example.id
5656
folder = "/home/coder/example"
5757
jetbrains_ides = ["IU", "PY"]
@@ -66,7 +66,7 @@ module "jetbrains_gateway" {
6666
module "jetbrains_gateway" {
6767
count = data.coder_workspace.me.start_count
6868
source = "registry.coder.com/coder/jetbrains-gateway/coder"
69-
version = "1.2.3"
69+
version = "1.2.4"
7070
agent_id = coder_agent.example.id
7171
folder = "/home/coder/example"
7272
jetbrains_ides = ["IU", "PY"]
@@ -91,7 +91,7 @@ module "jetbrains_gateway" {
9191
module "jetbrains_gateway" {
9292
count = data.coder_workspace.me.start_count
9393
source = "registry.coder.com/coder/jetbrains-gateway/coder"
94-
version = "1.2.3"
94+
version = "1.2.4"
9595
agent_id = coder_agent.example.id
9696
folder = "/home/coder/example"
9797
jetbrains_ides = ["GO", "WS"]
@@ -109,7 +109,7 @@ Due to the highest priority of the `ide_download_link` parameter in the `(jetbra
109109
module "jetbrains_gateway" {
110110
count = data.coder_workspace.me.start_count
111111
source = "registry.coder.com/coder/jetbrains-gateway/coder"
112-
version = "1.2.3"
112+
version = "1.2.4"
113113
agent_id = coder_agent.example.id
114114
folder = "/home/coder/example"
115115
jetbrains_ides = ["GO", "WS"]

registry/coder/modules/jetbrains-gateway/main.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("jetbrains-gateway", async () => {
2020
folder: "/home/coder",
2121
});
2222
expect(state.outputs.url.value).toBe(
23-
"jetbrains-gateway://connect#type=coder&workspace=default&owner=default&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=243.21565.193&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.3.tar.gz&agent_id=foo",
23+
"jetbrains-gateway://connect#type=coder&workspace=default&owner=default&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=243.21565.193&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.3.tar.gz&agent=",
2424
);
2525

2626
const coder_app = state.resources.find(
@@ -40,4 +40,28 @@ describe("jetbrains-gateway", async () => {
4040
});
4141
expect(state.outputs.identifier.value).toBe("IU");
4242
});
43+
44+
it("optionally includes agent when an agent name is provided", async () => {
45+
const state = await runTerraformApply(import.meta.dir, {
46+
agent_id: "foo",
47+
agent_name: "main",
48+
folder: "/home/coder",
49+
});
50+
51+
expect(state.outputs.url.value).toBe(
52+
"jetbrains-gateway://connect#type=coder&workspace=default&owner=default&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=243.21565.193&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.3.tar.gz&agent=main",
53+
);
54+
});
55+
56+
it("includes the agent parameter even when the provided value is blank", async () => {
57+
const state = await runTerraformApply(import.meta.dir, {
58+
agent_id: "foo",
59+
agent_name: " ",
60+
folder: "/home/coder",
61+
});
62+
63+
expect(state.outputs.url.value).toBe(
64+
"jetbrains-gateway://connect#type=coder&workspace=default&owner=default&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=243.21565.193&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.3.tar.gz&agent= ",
65+
);
66+
});
4367
});

registry/coder/modules/jetbrains-gateway/main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ variable "slug" {
3636

3737
variable "agent_name" {
3838
type = string
39-
description = "Agent name. (unused). Will be removed in a future version"
40-
41-
default = ""
39+
description = "Agent name."
40+
default = ""
4241
}
4342

4443
variable "folder" {
@@ -348,8 +347,8 @@ resource "coder_app" "gateway" {
348347
local.build_number,
349348
"&ide_download_link=",
350349
local.download_link,
351-
"&agent_id=",
352-
var.agent_id,
350+
"&agent=",
351+
var.agent_name,
353352
])
354353
}
355354

0 commit comments

Comments
 (0)