Skip to content

Commit ef8ad09

Browse files
committed
Add agent_name to JetBrains module URLs
Add agent_name parameter to URLs for workspaces with multiple agents. Updated tests to ensure correct URL generation, with and without agent_name specified.
1 parent c251fbf commit ef8ad09

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,27 @@ describe("jetbrains", async () => {
300300
expect(url).toContain("&token=$SESSION_TOKEN");
301301
expect(url).toContain("&ide_product_code=GO");
302302
expect(url).toContain("&ide_build_number=");
303-
expect(url).toContain("&agent_id=test-agent-123");
303+
// No agent_name parameter should be included when agent_name is not specified
304+
expect(url).not.toContain("&agent_name=");
305+
});
306+
307+
it("should include agent_name parameter when agent_name is specified", async () => {
308+
const state = await runTerraformApply(import.meta.dir, {
309+
agent_id: "test-agent-123",
310+
agent_name: "main-agent",
311+
folder: "/custom/project/path",
312+
default: '["GO"]',
313+
});
314+
315+
const coder_app = state.resources.find(
316+
(res) => res.type === "coder_app" && res.name === "jetbrains",
317+
);
318+
const url = coder_app?.instances[0].attributes.url;
319+
320+
expect(url).toContain("jetbrains://gateway/coder");
321+
expect(url).toContain("&agent_name=main-agent");
322+
expect(url).toContain("&ide_product_code=GO");
323+
expect(url).toContain("&ide_build_number=");
304324
});
305325

306326
it("should include build numbers from API in URLs", async () => {

registry/coder/modules/jetbrains/main.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ terraform {
1515

1616
variable "agent_id" {
1717
type = string
18-
description = "The ID of a Coder agent."
18+
description = "The resource ID of a Coder agent."
19+
}
20+
21+
variable "agent_name" {
22+
type = string
23+
description = "The name of a Coder agent. Needed for workspaces with multiple agents."
24+
default = null
1925
}
2026

2127
variable "folder" {
@@ -239,7 +245,6 @@ resource "coder_app" "jetbrains" {
239245
each.key,
240246
"&ide_build_number=",
241247
local.options_metadata[each.key].build,
242-
"&agent_id=",
243-
var.agent_id,
248+
var.agent_name != null ? "&agent_name=${var.agent_name}" : "",
244249
])
245250
}

0 commit comments

Comments
 (0)