Skip to content

Commit ac15f0c

Browse files
committed
chore(dogfood): add IDE selection parameter
Introduce a new multi-select parameter `ide_choices` for selecting IDEs to enable in workspaces. Update modules to configure based on selected IDEs, allowing dynamic workspace customization. Add logic to display or start apps based on selected choices, enhancing flexibility in IDE management.
1 parent a2fc261 commit ac15f0c

File tree

1 file changed

+80
-8
lines changed

1 file changed

+80
-8
lines changed

dogfood/coder/main.tf

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ locals {
167167
], ["us-pittsburgh"])[0]
168168
}
169169

170-
171170
data "coder_parameter" "region" {
172171
type = "string"
173172
name = "Region"
@@ -261,6 +260,74 @@ data "coder_workspace_tags" "tags" {
261260
}
262261
}
263262

263+
data "coder_parameter" "ide_choices" {
264+
type = "list(string)"
265+
name = "Select IDEs"
266+
form_type = "multi-select"
267+
mutable = true
268+
description = "Choose one or more IDEs to enable in your workspace"
269+
default = jsonencode(["vscode", "code-server", "cursor"])
270+
option {
271+
name = "VS Code Desktop"
272+
value = "vscode"
273+
icon = "/icon/code.svg"
274+
}
275+
option {
276+
name = "code-server"
277+
value = "code-server"
278+
icon = "/icon/code.svg"
279+
}
280+
option {
281+
name = "VS Code Web"
282+
value = "vscode-web"
283+
icon = "/icon/code.svg"
284+
}
285+
option {
286+
name = "JetBrains IDEs"
287+
value = "jetbrains"
288+
icon = "/icon/jetbrains.svg"
289+
}
290+
option {
291+
name = "JetBrains Fleet"
292+
value = "fleet"
293+
icon = "/icon/fleet.svg"
294+
}
295+
option {
296+
name = "Cursor"
297+
value = "cursor"
298+
icon = "/icon/cursor.svg"
299+
}
300+
option {
301+
name = "Windsurf"
302+
value = "windsurf"
303+
icon = "/icon/windsurf.svg"
304+
}
305+
option {
306+
name = "Zed"
307+
value = "zed"
308+
icon = "/icon/zed.svg"
309+
}
310+
}
311+
312+
data "coder_parameter" "vscode_channel" {
313+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "vscode") ? data.coder_workspace.me.start_count : 0
314+
type = "string"
315+
name = "VS Code Desktop channel"
316+
description = "Choose the VS Code Desktop channel"
317+
mutable = true
318+
default = "stable"
319+
option {
320+
value = "stable"
321+
name = "Stable"
322+
icon = "/icon/code.svg"
323+
}
324+
option {
325+
value = "insiders"
326+
name = "Insiders"
327+
icon = "/icon/code-insiders.svg"
328+
}
329+
}
330+
264331
module "slackme" {
265332
count = data.coder_workspace.me.start_count
266333
source = "dev.registry.coder.com/coder/slackme/coder"
@@ -293,7 +360,7 @@ module "personalize" {
293360
}
294361

295362
module "code-server" {
296-
count = data.coder_workspace.me.start_count
363+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "code-server") ? data.coder_workspace.me.start_count : 0
297364
source = "dev.registry.coder.com/coder/code-server/coder"
298365
version = "1.3.1"
299366
agent_id = coder_agent.dev.id
@@ -303,7 +370,7 @@ module "code-server" {
303370
}
304371

305372
module "vscode-web" {
306-
count = data.coder_workspace.me.start_count
373+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "vscode-web") ? data.coder_workspace.me.start_count : 0
307374
source = "dev.registry.coder.com/coder/vscode-web/coder"
308375
version = "1.3.1"
309376
agent_id = coder_agent.dev.id
@@ -315,7 +382,7 @@ module "vscode-web" {
315382
}
316383

317384
module "jetbrains" {
318-
count = data.coder_workspace.me.start_count
385+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "jetbrains") ? data.coder_workspace.me.start_count : 0
319386
source = "dev.registry.coder.com/coder/jetbrains/coder"
320387
version = "1.0.0"
321388
agent_id = coder_agent.dev.id
@@ -340,23 +407,23 @@ module "coder-login" {
340407
}
341408

342409
module "cursor" {
343-
count = data.coder_workspace.me.start_count
410+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "cursor") ? data.coder_workspace.me.start_count : 0
344411
source = "dev.registry.coder.com/coder/cursor/coder"
345412
version = "1.2.1"
346413
agent_id = coder_agent.dev.id
347414
folder = local.repo_dir
348415
}
349416

350417
module "windsurf" {
351-
count = data.coder_workspace.me.start_count
418+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "windsurf") ? data.coder_workspace.me.start_count : 0
352419
source = "dev.registry.coder.com/coder/windsurf/coder"
353420
version = "1.1.1"
354421
agent_id = coder_agent.dev.id
355422
folder = local.repo_dir
356423
}
357424

358425
module "zed" {
359-
count = data.coder_workspace.me.start_count
426+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "zed") ? data.coder_workspace.me.start_count : 0
360427
source = "dev.registry.coder.com/coder/zed/coder"
361428
version = "1.0.1"
362429
agent_id = coder_agent.dev.id
@@ -365,7 +432,7 @@ module "zed" {
365432
}
366433

367434
module "jetbrains-fleet" {
368-
count = data.coder_workspace.me.start_count
435+
count = contains(jsondecode(data.coder_parameter.ide_choices.value), "fleet") ? data.coder_workspace.me.start_count : 0
369436
source = "registry.coder.com/coder/jetbrains-fleet/coder"
370437
version = "1.0.1"
371438
agent_id = coder_agent.dev.id
@@ -389,6 +456,11 @@ resource "coder_agent" "dev" {
389456
}
390457
startup_script_behavior = "blocking"
391458

459+
display_apps {
460+
vscode = contains(jsondecode(data.coder_parameter.ide_choices.value), "vscode") && try(data.coder_parameter.vscode_channel[0].value, "") == "stable"
461+
vscode_insiders = contains(jsondecode(data.coder_parameter.ide_choices.value), "vscode") && try(data.coder_parameter.vscode_channel[0].value, "") == "insiders"
462+
}
463+
392464
# The following metadata blocks are optional. They are used to display
393465
# information about your workspace in the dashboard. You can remove them
394466
# if you don't want to display any information.

0 commit comments

Comments
 (0)