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
12 changes: 6 additions & 6 deletions registry/coder/modules/zed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Zed is a high-performance, multiplayer code editor from the creators of Atom and
module "zed" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/zed/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
}
```
Expand All @@ -32,7 +32,7 @@ module "zed" {
module "zed" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/zed/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
folder = "/home/coder/project"
}
Expand All @@ -44,7 +44,7 @@ module "zed" {
module "zed" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/zed/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
display_name = "Zed Editor"
order = 1
Expand All @@ -57,7 +57,7 @@ module "zed" {
module "zed" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/zed/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id
agent_name = coder_agent.example.name
}
Expand All @@ -73,7 +73,7 @@ You can declaratively set/merge settings with the `settings` input. Provide a JS
module "zed" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/zed/coder"
version = "1.1.4"
version = "1.1.5"
agent_id = coder_agent.main.id

settings = jsonencode({
Expand All @@ -91,4 +91,4 @@ module "zed" {
}
```

See Zeds settings files documentation: https://zed.dev/docs/configuring-zed#settings-files
See Zed's settings files documentation: https://zed.dev/docs/configuring-zed#settings-files
23 changes: 6 additions & 17 deletions registry/coder/modules/zed/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,16 @@ describe("zed", async () => {
}
}, 30000);

it("exits early with empty settings", async () => {
it("does not create coder_script when settings is empty", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
settings: "",
});

const instance = findResourceInstance(state, "coder_script");
const id = await runContainer("alpine:latest");

try {
const result = await execContainer(id, ["sh", "-c", instance.script]);
expect(result.exitCode).toBe(0);

// Settings file should not be created
const catResult = await execContainer(id, [
"cat",
"/root/.config/zed/settings.json",
]);
expect(catResult.exitCode).not.toBe(0);
} finally {
await removeContainer(id);
}
// With count = 0, no coder_script resource should exist
const scripts = state.resources?.filter(
(r: { type: string }) => r.type === "coder_script",
);
expect(scripts?.length ?? 0).toBe(0);
}, 30000);
});
4 changes: 1 addition & 3 deletions registry/coder/modules/zed/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ locals {
}

resource "coder_script" "zed_settings" {
count = var.settings != "" ? 1 : 0
agent_id = var.agent_id
display_name = "Configure Zed settings"
icon = "/icon/zed.svg"
Expand All @@ -77,9 +78,6 @@ resource "coder_script" "zed_settings" {
#!/usr/bin/env bash
set -eu
SETTINGS_B64='${local.settings_b64}'
if [ -z "$${SETTINGS_B64}" ]; then
exit 0
fi
SETTINGS_JSON="$(echo -n "$${SETTINGS_B64}" | base64 -d)"
if [ -z "$${SETTINGS_JSON}" ] || [ "$${SETTINGS_JSON}" = "{}" ]; then
exit 0
Expand Down
8 changes: 4 additions & 4 deletions registry/coder/modules/zed/zed.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ run "settings_base64_encoding" {

# Verify settings are base64 encoded (eyJ = base64 prefix for JSON starting with {")
assert {
condition = can(regex("SETTINGS_B64='eyJ", coder_script.zed_settings.script))
condition = can(regex("SETTINGS_B64='eyJ", coder_script.zed_settings[0].script))
error_message = "settings should be base64 encoded in the script"
}
}

run "empty_settings" {
run "empty_settings_no_script" {
command = apply

variables {
Expand All @@ -108,7 +108,7 @@ run "empty_settings" {
}

assert {
condition = can(regex("SETTINGS_B64=''", coder_script.zed_settings.script))
error_message = "empty settings should result in empty SETTINGS_B64"
condition = length(coder_script.zed_settings) == 0
error_message = "coder_script should not be created when settings is empty"
}
}
Loading