Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 8a0ac34

Browse files
authored
Add owner to Gateway link (#310)
Without this, it is not possible to reliably connect to another user's workspace (for admins, mainly) when duplicate workspace names are involved.
1 parent 438c904 commit 8a0ac34

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

jetbrains-gateway/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This module adds a JetBrains Gateway Button to open any workspace with a single
1414
```tf
1515
module "jetbrains_gateway" {
1616
source = "registry.coder.com/modules/jetbrains-gateway/coder"
17-
version = "1.0.13"
17+
version = "1.0.20"
1818
agent_id = coder_agent.example.id
1919
agent_name = "example"
2020
folder = "/home/coder/example"
@@ -32,7 +32,7 @@ module "jetbrains_gateway" {
3232
```tf
3333
module "jetbrains_gateway" {
3434
source = "registry.coder.com/modules/jetbrains-gateway/coder"
35-
version = "1.0.13"
35+
version = "1.0.20"
3636
agent_id = coder_agent.example.id
3737
agent_name = "example"
3838
folder = "/home/coder/example"
@@ -46,7 +46,7 @@ module "jetbrains_gateway" {
4646
```tf
4747
module "jetbrains_gateway" {
4848
source = "registry.coder.com/modules/jetbrains-gateway/coder"
49-
version = "1.0.13"
49+
version = "1.0.20"
5050
agent_id = coder_agent.example.id
5151
agent_name = "example"
5252
folder = "/home/coder/example"
@@ -61,7 +61,7 @@ module "jetbrains_gateway" {
6161
```tf
6262
module "jetbrains_gateway" {
6363
source = "registry.coder.com/modules/jetbrains-gateway/coder"
64-
version = "1.0.13"
64+
version = "1.0.20"
6565
agent_id = coder_agent.example.id
6666
agent_name = "example"
6767
folder = "/home/coder/example"

jetbrains-gateway/main.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ describe("jetbrains-gateway", async () => {
1414
folder: "/home/foo",
1515
});
1616

17+
it("should create a link with the default values", async () => {
18+
const state = await runTerraformApply(import.meta.dir, {
19+
// These are all required.
20+
agent_id: "foo",
21+
agent_name: "foo",
22+
folder: "/home/coder",
23+
});
24+
expect(state.outputs.url.value).toBe(
25+
"jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=241.14494.240&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.1.tar.gz",
26+
);
27+
28+
const coder_app = state.resources.find(
29+
(res) => res.type === "coder_app" && res.name === "gateway",
30+
);
31+
32+
expect(coder_app).not.toBeNull();
33+
expect(coder_app?.instances.length).toBe(1);
34+
expect(coder_app?.instances[0].attributes.order).toBeNull();
35+
});
36+
1737
it("default to first ide", async () => {
1838
const state = await runTerraformApply(import.meta.dir, {
1939
agent_id: "foo",

jetbrains-gateway/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ data "coder_parameter" "jetbrains_ide" {
243243
}
244244

245245
data "coder_workspace" "me" {}
246+
data "coder_workspace_owner" "me" {}
246247

247248
resource "coder_app" "gateway" {
248249
agent_id = var.agent_id
@@ -254,6 +255,8 @@ resource "coder_app" "gateway" {
254255
url = join("", [
255256
"jetbrains-gateway://connect#type=coder&workspace=",
256257
data.coder_workspace.me.name,
258+
"&owner=",
259+
data.coder_workspace_owner.me.name,
257260
"&agent=",
258261
var.agent_name,
259262
"&folder=",

0 commit comments

Comments
 (0)