Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions registry/coder/modules/filebrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A file browser for your workspace.
module "filebrowser" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/filebrowser/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
}
```
Expand All @@ -29,7 +29,7 @@ module "filebrowser" {
module "filebrowser" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/filebrowser/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
folder = "/home/coder/project"
}
Expand All @@ -41,19 +41,21 @@ module "filebrowser" {
module "filebrowser" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/filebrowser/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
database_path = ".config/filebrowser.db"
}
```

### Serve from the same domain (no subdomain)

When `subdomain = false`, you must also set `agent_name` to the name of your `coder_agent` resource. Coder serves path-based apps at `/@<owner>/<workspace>.<agent>/apps/<slug>/`, so the agent name is required to build a base URL that matches the URL the user is actually browsing. If `agent_name` is omitted in this mode, `terraform apply` will fail with an explanatory error.

```tf
module "filebrowser" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/filebrowser/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
agent_name = "main"
subdomain = false
Expand Down
15 changes: 15 additions & 0 deletions registry/coder/modules/filebrowser/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,19 @@ describe("filebrowser", async () => {

testBaseLine(output);
}, 15000);

it("fails when subdomain=false and agent_name is not provided", async () => {
let caught: Error | undefined;
try {
await runTerraformApply(import.meta.dir, {
agent_id: "foo",
subdomain: false,
});
} catch (e) {
caught = e as Error;
}
expect(caught).toBeDefined();
expect(caught!.message).toContain("agent_name");
expect(caught!.message).toContain("subdomain");
}, 15000);
});
9 changes: 8 additions & 1 deletion registry/coder/modules/filebrowser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data "coder_workspace_owner" "me" {}

variable "agent_name" {
type = string
description = "The name of the coder_agent resource. (Only required if subdomain is false and the template uses multiple agents.)"
description = "The name of the coder_agent resource. Required when `subdomain` is `false` so the path-based base URL matches the URL Coder serves."
default = null
}

Expand Down Expand Up @@ -102,6 +102,13 @@ resource "coder_script" "filebrowser" {
SERVER_BASE_PATH : local.server_base_path
})
run_on_start = true

lifecycle {
precondition {
condition = var.subdomain || var.agent_name != null
error_message = "`agent_name` is required when `subdomain` is `false`. Coder always builds path-based app URLs as `/@<owner>/<workspace>.<agent>/apps/<slug>/`, so the filebrowser base URL must include the agent name to match. Set `agent_name = \"<your coder_agent name>\"` (e.g. `\"main\"`)."
}
}
}

resource "coder_app" "filebrowser" {
Expand Down
Loading