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.
This commit is contained in:
Muhammad Atif Ali 2025-07-08 01:34:04 +05:00
parent c251fbfa9c
commit ef8ad092e1
No known key found for this signature in database
2 changed files with 29 additions and 4 deletions

View File

@ -300,7 +300,27 @@ describe("jetbrains", async () => {
expect(url).toContain("&token=$SESSION_TOKEN");
expect(url).toContain("&ide_product_code=GO");
expect(url).toContain("&ide_build_number=");
expect(url).toContain("&agent_id=test-agent-123");
// No agent_name parameter should be included when agent_name is not specified
expect(url).not.toContain("&agent_name=");
});
it("should include agent_name parameter when agent_name is specified", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "test-agent-123",
agent_name: "main-agent",
folder: "/custom/project/path",
default: '["GO"]',
});
const coder_app = state.resources.find(
(res) => res.type === "coder_app" && res.name === "jetbrains",
);
const url = coder_app?.instances[0].attributes.url;
expect(url).toContain("jetbrains://gateway/coder");
expect(url).toContain("&agent_name=main-agent");
expect(url).toContain("&ide_product_code=GO");
expect(url).toContain("&ide_build_number=");
});
it("should include build numbers from API in URLs", async () => {

View File

@ -15,7 +15,13 @@ terraform {
variable "agent_id" {
type = string
description = "The ID of a Coder agent."
description = "The resource ID of a Coder agent."
}
variable "agent_name" {
type = string
description = "The name of a Coder agent. Needed for workspaces with multiple agents."
default = null
}
variable "folder" {
@ -239,7 +245,6 @@ resource "coder_app" "jetbrains" {
each.key,
"&ide_build_number=",
local.options_metadata[each.key].build,
"&agent_id=",
var.agent_id,
var.agent_name != null ? "&agent_name=${var.agent_name}" : "",
])
}