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

Commit 1628087

Browse files
authored
fix(filebrowser): only require agent_name when not on subdomain (#299)
1 parent ad1189a commit 1628087

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

filebrowser/README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ A file browser for your workspace.
1313

1414
```tf
1515
module "filebrowser" {
16-
source = "registry.coder.com/modules/filebrowser/coder"
17-
version = "1.0.18"
18-
agent_id = coder_agent.example.id
19-
agent_name = "main"
16+
source = "registry.coder.com/modules/filebrowser/coder"
17+
version = "1.0.18"
18+
agent_id = coder_agent.example.id
2019
}
2120
```
2221

@@ -28,11 +27,10 @@ module "filebrowser" {
2827

2928
```tf
3029
module "filebrowser" {
31-
source = "registry.coder.com/modules/filebrowser/coder"
32-
version = "1.0.18"
33-
agent_id = coder_agent.example.id
34-
agent_name = "main"
35-
folder = "/home/coder/project"
30+
source = "registry.coder.com/modules/filebrowser/coder"
31+
version = "1.0.18"
32+
agent_id = coder_agent.example.id
33+
folder = "/home/coder/project"
3634
}
3735
```
3836

@@ -43,7 +41,6 @@ module "filebrowser" {
4341
source = "registry.coder.com/modules/filebrowser/coder"
4442
version = "1.0.18"
4543
agent_id = coder_agent.example.id
46-
agent_name = "main"
4744
database_path = ".config/filebrowser.db"
4845
}
4946
```

filebrowser/main.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ describe("filebrowser", async () => {
1111

1212
testRequiredVariables(import.meta.dir, {
1313
agent_id: "foo",
14-
agent_name: "main",
1514
});
1615

1716
it("fails with wrong database_path", async () => {
1817
const state = await runTerraformApply(import.meta.dir, {
1918
agent_id: "foo",
20-
agent_name: "main",
2119
database_path: "nofb",
2220
}).catch((e) => {
2321
if (!e.message.startsWith("\nError: Invalid value for variable")) {
@@ -29,7 +27,6 @@ describe("filebrowser", async () => {
2927
it("runs with default", async () => {
3028
const state = await runTerraformApply(import.meta.dir, {
3129
agent_id: "foo",
32-
agent_name: "main",
3330
});
3431
const output = await executeScriptInContainer(state, "alpine");
3532
expect(output.exitCode).toBe(0);
@@ -51,7 +48,6 @@ describe("filebrowser", async () => {
5148
it("runs with database_path var", async () => {
5249
const state = await runTerraformApply(import.meta.dir, {
5350
agent_id: "foo",
54-
agent_name: "main",
5551
database_path: ".config/filebrowser.db",
5652
});
5753
const output = await executeScriptInContainer(state, "alpine");
@@ -74,7 +70,6 @@ describe("filebrowser", async () => {
7470
it("runs with folder var", async () => {
7571
const state = await runTerraformApply(import.meta.dir, {
7672
agent_id: "foo",
77-
agent_name: "main",
7873
folder: "/home/coder/project",
7974
});
8075
const output = await executeScriptInContainer(state, "alpine");

filebrowser/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ data "coder_workspace_owner" "me" {}
2121
variable "agent_name" {
2222
type = string
2323
description = "The name of the main deployment. (Used to build the subpath for coder_app.)"
24+
default = ""
25+
validation {
26+
# If subdomain is false, then agent_name must be set.
27+
condition = var.subdomain || var.agent_name != ""
28+
error_message = "The agent_name must be set."
29+
}
2430
}
2531

2632
variable "database_path" {

0 commit comments

Comments
 (0)