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

fix(filebrowser): only require agent_name when not on subdomain #299

Merged
merged 4 commits into from
Sep 27, 2024
Merged
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
17 changes: 7 additions & 10 deletions filebrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ A file browser for your workspace.

```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18"
agent_id = coder_agent.example.id
agent_name = "main"
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18"
agent_id = coder_agent.example.id
}
```

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

```tf
module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18"
agent_id = coder_agent.example.id
agent_name = "main"
folder = "/home/coder/project"
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18"
agent_id = coder_agent.example.id
folder = "/home/coder/project"
}
```

Expand All @@ -43,7 +41,6 @@ module "filebrowser" {
source = "registry.coder.com/modules/filebrowser/coder"
version = "1.0.18"
agent_id = coder_agent.example.id
agent_name = "main"
database_path = ".config/filebrowser.db"
}
```
Expand Down
5 changes: 0 additions & 5 deletions filebrowser/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ describe("filebrowser", async () => {

testRequiredVariables(import.meta.dir, {
agent_id: "foo",
agent_name: "main",
});

it("fails with wrong database_path", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
agent_name: "main",
database_path: "nofb",
}).catch((e) => {
if (!e.message.startsWith("\nError: Invalid value for variable")) {
Expand All @@ -29,7 +27,6 @@ describe("filebrowser", async () => {
it("runs with default", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
agent_name: "main",
});
const output = await executeScriptInContainer(state, "alpine");
expect(output.exitCode).toBe(0);
Expand All @@ -51,7 +48,6 @@ describe("filebrowser", async () => {
it("runs with database_path var", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
agent_name: "main",
database_path: ".config/filebrowser.db",
});
const output = await executeScriptInContainer(state, "alpine");
Expand All @@ -74,7 +70,6 @@ describe("filebrowser", async () => {
it("runs with folder var", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
agent_name: "main",
folder: "/home/coder/project",
});
const output = await executeScriptInContainer(state, "alpine");
Expand Down
6 changes: 6 additions & 0 deletions filebrowser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ data "coder_workspace_owner" "me" {}
variable "agent_name" {
type = string
description = "The name of the main deployment. (Used to build the subpath for coder_app.)"
default = ""
validation {
# If subdomain is false, then agent_name must be set.
condition = var.subdomain || var.agent_name != ""
error_message = "The agent_name must be set."
}
}

variable "database_path" {
Expand Down