## 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
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import { it, expect, describe } from "bun:test";
|
|
import {
|
|
runTerraformInit,
|
|
testRequiredVariables,
|
|
runTerraformApply,
|
|
} from "~test";
|
|
|
|
describe("jetbrains-gateway", async () => {
|
|
await runTerraformInit(import.meta.dir);
|
|
|
|
await testRequiredVariables(import.meta.dir, {
|
|
agent_id: "foo",
|
|
folder: "/home/foo",
|
|
});
|
|
|
|
it("should create a link with the default values", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
// These are all required.
|
|
agent_id: "foo",
|
|
folder: "/home/coder",
|
|
});
|
|
expect(state.outputs.url.value).toBe(
|
|
"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=",
|
|
);
|
|
|
|
const coder_app = state.resources.find(
|
|
(res) => res.type === "coder_app" && res.name === "gateway",
|
|
);
|
|
|
|
expect(coder_app).not.toBeNull();
|
|
expect(coder_app?.instances.length).toBe(1);
|
|
expect(coder_app?.instances[0].attributes.order).toBeNull();
|
|
});
|
|
|
|
it("default to first ide", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
folder: "/home/foo",
|
|
jetbrains_ides: '["IU", "GO", "PY"]',
|
|
});
|
|
expect(state.outputs.identifier.value).toBe("IU");
|
|
});
|
|
|
|
it("optionally includes agent when an agent name is provided", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
agent_name: "main",
|
|
folder: "/home/coder",
|
|
});
|
|
|
|
expect(state.outputs.url.value).toBe(
|
|
"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",
|
|
);
|
|
});
|
|
|
|
it("includes the agent parameter even when the provided value is blank", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
agent_name: " ",
|
|
folder: "/home/coder",
|
|
});
|
|
|
|
expect(state.outputs.url.value).toBe(
|
|
"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= ",
|
|
);
|
|
});
|
|
});
|