Skip to content

Commit da8e296

Browse files
kourylapeDevelopmentCatsblink-so[bot]
authored
Fix/dotfiles fish compatibility (#682)
## Description The dotfiles module does not work when using non-POSIX shells i.e. Fish. ## Type of Change - [ ] New module - [ ] New template - [x] Bug fix - [x] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information **Path:** `registry/coder/modules/dotfiles` **New version:** `v1.4.1` **Breaking change:** [ ] Yes [ ] No ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun fmt`) - [x] Changes tested locally ``` bun test v1.3.8 (b64edcb4) registry/coder/modules/dotfiles/main.test.ts: ✓ dotfiles > required variables [190.40ms] ✓ dotfiles > missing variable: agent_id [43.12ms] ✓ dotfiles > default output [150.15ms] ✓ dotfiles > set a default dotfiles_uri [159.14ms] ✓ dotfiles > command uses bash for fish shell compatibility [164.08ms] ✓ dotfiles > set custom order for coder_parameter [166.50ms] 6 pass 0 fail 7 expect() calls Ran 6 tests across 1 file. [1184.00ms] ``` I tested this with a new workspace on Coder v2.27.3 with fish, zsh, and bash. --------- Co-authored-by: DevCats <christofer@coder.com> Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
1 parent ce50e52 commit da8e296

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

registry/coder/modules/dotfiles/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Under the hood, this module uses the [coder dotfiles](https://coder.com/docs/v2/
1818
module "dotfiles" {
1919
count = data.coder_workspace.me.start_count
2020
source = "registry.coder.com/coder/dotfiles/coder"
21-
version = "1.4.0"
21+
version = "1.4.1"
2222
agent_id = coder_agent.example.id
2323
}
2424
```
@@ -31,7 +31,7 @@ module "dotfiles" {
3131
module "dotfiles" {
3232
count = data.coder_workspace.me.start_count
3333
source = "registry.coder.com/coder/dotfiles/coder"
34-
version = "1.4.0"
34+
version = "1.4.1"
3535
agent_id = coder_agent.example.id
3636
}
3737
```
@@ -42,7 +42,7 @@ module "dotfiles" {
4242
module "dotfiles" {
4343
count = data.coder_workspace.me.start_count
4444
source = "registry.coder.com/coder/dotfiles/coder"
45-
version = "1.4.0"
45+
version = "1.4.1"
4646
agent_id = coder_agent.example.id
4747
user = "root"
4848
}
@@ -54,14 +54,14 @@ module "dotfiles" {
5454
module "dotfiles" {
5555
count = data.coder_workspace.me.start_count
5656
source = "registry.coder.com/coder/dotfiles/coder"
57-
version = "1.4.0"
57+
version = "1.4.1"
5858
agent_id = coder_agent.example.id
5959
}
6060
6161
module "dotfiles-root" {
6262
count = data.coder_workspace.me.start_count
6363
source = "registry.coder.com/coder/dotfiles/coder"
64-
version = "1.4.0"
64+
version = "1.4.1"
6565
agent_id = coder_agent.example.id
6666
user = "root"
6767
dotfiles_uri = module.dotfiles.dotfiles_uri
@@ -90,7 +90,7 @@ You can set a default dotfiles repository for all users by setting the `default_
9090
module "dotfiles" {
9191
count = data.coder_workspace.me.start_count
9292
source = "registry.coder.com/coder/dotfiles/coder"
93-
version = "1.4.0"
93+
version = "1.4.1"
9494
agent_id = coder_agent.example.id
9595
default_dotfiles_uri = "https://github.com/coder/dotfiles"
9696
}

registry/coder/modules/dotfiles/main.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ describe("dotfiles", async () => {
5656
}
5757
});
5858

59+
it("command uses bash for fish shell compatibility", async () => {
60+
const state = await runTerraformApply(import.meta.dir, {
61+
agent_id: "foo",
62+
manual_update: "true",
63+
dotfiles_uri: "https://github.com/test/dotfiles",
64+
});
65+
66+
const app = state.resources.find(
67+
(r) => r.type === "coder_app" && r.name === "dotfiles",
68+
);
69+
70+
expect(app).toBeDefined();
71+
expect(app?.instances[0]?.attributes?.command).toContain("/bin/bash -c");
72+
});
73+
5974
it("set custom order for coder_parameter", async () => {
6075
const order = 99;
6176
const state = await runTerraformApply(import.meta.dir, {

registry/coder/modules/dotfiles/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ resource "coder_app" "dotfiles" {
164164
icon = "/icon/dotfiles.svg"
165165
order = var.order
166166
group = var.group
167-
command = templatefile("${path.module}/run.sh", {
167+
command = "/bin/bash -c \"$(echo ${base64encode(templatefile("${path.module}/run.sh", {
168168
DOTFILES_URI : local.dotfiles_uri,
169169
DOTFILES_USER : local.user,
170170
DOTFILES_BRANCH : local.dotfiles_branch,
171171
POST_CLONE_SCRIPT : local.encoded_post_clone_script
172-
})
172+
}))} | base64 -d)\""
173173
}
174174

175175
output "dotfiles_uri" {

0 commit comments

Comments
 (0)