Skip to content

Commit 261fd1f

Browse files
Merge branch 'main' into fix-codex-2-2-0
2 parents 83c2ebb + da5a2ba commit 261fd1f

File tree

9 files changed

+93
-25
lines changed

9 files changed

+93
-25
lines changed

registry/coder/modules/amazon-q/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run [Amazon Q](https://aws.amazon.com/q/) in your workspace to access Amazon's A
1313
```tf
1414
module "amazon-q" {
1515
source = "registry.coder.com/coder/amazon-q/coder"
16-
version = "2.1.0"
16+
version = "2.1.1"
1717
agent_id = coder_agent.example.id
1818
workdir = "/home/coder"
1919
@@ -102,7 +102,7 @@ data "coder_parameter" "ai_prompt" {
102102
103103
module "amazon-q" {
104104
source = "registry.coder.com/coder/amazon-q/coder"
105-
version = "2.1.0"
105+
version = "2.1.1"
106106
agent_id = coder_agent.example.id
107107
workdir = "/home/coder"
108108
auth_tarball = var.amazon_q_auth_tarball
@@ -228,7 +228,7 @@ If no custom `agent_config` is provided, the default agent name "agent" is used.
228228
```tf
229229
module "amazon-q" {
230230
source = "registry.coder.com/coder/amazon-q/coder"
231-
version = "2.1.0"
231+
version = "2.1.1"
232232
agent_id = coder_agent.example.id
233233
workdir = "/home/coder"
234234
auth_tarball = var.amazon_q_auth_tarball
@@ -258,7 +258,7 @@ This example will:
258258
```tf
259259
module "amazon-q" {
260260
source = "registry.coder.com/coder/amazon-q/coder"
261-
version = "2.1.0"
261+
version = "2.1.1"
262262
agent_id = coder_agent.example.id
263263
workdir = "/home/coder"
264264
auth_tarball = var.amazon_q_auth_tarball
@@ -279,7 +279,7 @@ module "amazon-q" {
279279
```tf
280280
module "amazon-q" {
281281
source = "registry.coder.com/coder/amazon-q/coder"
282-
version = "2.1.0"
282+
version = "2.1.1"
283283
agent_id = coder_agent.example.id
284284
workdir = "/home/coder"
285285
auth_tarball = var.amazon_q_auth_tarball
@@ -305,7 +305,7 @@ module "amazon-q" {
305305
```tf
306306
module "amazon-q" {
307307
source = "registry.coder.com/coder/amazon-q/coder"
308-
version = "2.1.0"
308+
version = "2.1.1"
309309
agent_id = coder_agent.example.id
310310
workdir = "/home/coder"
311311
auth_tarball = var.amazon_q_auth_tarball
@@ -319,7 +319,7 @@ module "amazon-q" {
319319
```tf
320320
module "amazon-q" {
321321
source = "registry.coder.com/coder/amazon-q/coder"
322-
version = "2.1.0"
322+
version = "2.1.1"
323323
agent_id = coder_agent.example.id
324324
workdir = "/home/coder"
325325
auth_tarball = var.amazon_q_auth_tarball
@@ -340,7 +340,7 @@ module "amazon-q" {
340340
```tf
341341
module "amazon-q" {
342342
source = "registry.coder.com/coder/amazon-q/coder"
343-
version = "2.1.0"
343+
version = "2.1.1"
344344
agent_id = coder_agent.example.id
345345
workdir = "/home/coder"
346346
auth_tarball = var.amazon_q_auth_tarball
@@ -358,7 +358,7 @@ For environments without direct internet access, you can host Amazon Q installat
358358
```tf
359359
module "amazon-q" {
360360
source = "registry.coder.com/coder/amazon-q/coder"
361-
version = "2.1.0"
361+
version = "2.1.1"
362362
agent_id = coder_agent.example.id
363363
workdir = "/home/coder"
364364
auth_tarball = var.amazon_q_auth_tarball

registry/coder/modules/amazon-q/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ variable "workdir" {
9696
description = "The folder to run Amazon Q in."
9797
}
9898

99-
# ---------------------------------------------
100-
10199
variable "install_amazon_q" {
102100
type = bool
103101
description = "Whether to install Amazon Q."
@@ -190,6 +188,7 @@ resource "coder_env" "auth_tarball" {
190188

191189
locals {
192190
app_slug = "amazonq"
191+
workdir = trimsuffix(var.workdir, "/")
193192
install_script = file("${path.module}/scripts/install.sh")
194193
start_script = file("${path.module}/scripts/start.sh")
195194
module_dir_name = ".amazonq-module"
@@ -218,6 +217,7 @@ module "agentapi" {
218217
version = "1.2.0"
219218

220219
agent_id = var.agent_id
220+
folder = local.workdir
221221
web_app_slug = local.app_slug
222222
web_app_order = var.order
223223
web_app_group = var.group

registry/coder/modules/amazon-q/scripts/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ function install_amazon_q() {
9494
function extract_auth_tarball() {
9595
if [ -n "$ARG_AUTH_TARBALL" ]; then
9696
echo "Extracting auth tarball..."
97+
98+
if ! command_exists zstd; then
99+
echo "Error: zstd is required to extract the authentication tarball but is not installed."
100+
echo "Please install zstd using the pre_install_script parameter."
101+
exit 1
102+
fi
103+
97104
PREV_DIR="$PWD"
98105
echo "$ARG_AUTH_TARBALL" | base64 -d > /tmp/auth.tar.zst
99106
rm -rf ~/.local/share/amazon-q

registry/coder/modules/git-clone/README.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This module allows you to automatically clone a repository by URL and skip if it
1414
module "git-clone" {
1515
count = data.coder_workspace.me.start_count
1616
source = "registry.coder.com/coder/git-clone/coder"
17-
version = "1.1.2"
17+
version = "1.2.0"
1818
agent_id = coder_agent.example.id
1919
url = "https://github.com/coder/coder"
2020
}
@@ -28,7 +28,7 @@ module "git-clone" {
2828
module "git-clone" {
2929
count = data.coder_workspace.me.start_count
3030
source = "registry.coder.com/coder/git-clone/coder"
31-
version = "1.1.2"
31+
version = "1.2.0"
3232
agent_id = coder_agent.example.id
3333
url = "https://github.com/coder/coder"
3434
base_dir = "~/projects/coder"
@@ -43,7 +43,7 @@ To use with [Git Authentication](https://coder.com/docs/v2/latest/admin/git-prov
4343
module "git-clone" {
4444
count = data.coder_workspace.me.start_count
4545
source = "registry.coder.com/coder/git-clone/coder"
46-
version = "1.1.2"
46+
version = "1.2.0"
4747
agent_id = coder_agent.example.id
4848
url = "https://github.com/coder/coder"
4949
}
@@ -69,7 +69,7 @@ data "coder_parameter" "git_repo" {
6969
module "git_clone" {
7070
count = data.coder_workspace.me.start_count
7171
source = "registry.coder.com/coder/git-clone/coder"
72-
version = "1.1.2"
72+
version = "1.2.0"
7373
agent_id = coder_agent.example.id
7474
url = data.coder_parameter.git_repo.value
7575
}
@@ -103,7 +103,7 @@ Configuring `git-clone` for a self-hosted GitHub Enterprise Server running at `g
103103
module "git-clone" {
104104
count = data.coder_workspace.me.start_count
105105
source = "registry.coder.com/coder/git-clone/coder"
106-
version = "1.1.2"
106+
version = "1.2.0"
107107
agent_id = coder_agent.example.id
108108
url = "https://github.example.com/coder/coder/tree/feat/example"
109109
git_providers = {
@@ -122,7 +122,7 @@ To GitLab clone with a specific branch like `feat/example`
122122
module "git-clone" {
123123
count = data.coder_workspace.me.start_count
124124
source = "registry.coder.com/coder/git-clone/coder"
125-
version = "1.1.2"
125+
version = "1.2.0"
126126
agent_id = coder_agent.example.id
127127
url = "https://gitlab.com/coder/coder/-/tree/feat/example"
128128
}
@@ -134,7 +134,7 @@ Configuring `git-clone` for a self-hosted GitLab running at `gitlab.example.com`
134134
module "git-clone" {
135135
count = data.coder_workspace.me.start_count
136136
source = "registry.coder.com/coder/git-clone/coder"
137-
version = "1.1.2"
137+
version = "1.2.0"
138138
agent_id = coder_agent.example.id
139139
url = "https://gitlab.example.com/coder/coder/-/tree/feat/example"
140140
git_providers = {
@@ -155,7 +155,7 @@ For example, to clone the `feat/example` branch:
155155
module "git-clone" {
156156
count = data.coder_workspace.me.start_count
157157
source = "registry.coder.com/coder/git-clone/coder"
158-
version = "1.1.2"
158+
version = "1.2.0"
159159
agent_id = coder_agent.example.id
160160
url = "https://github.com/coder/coder"
161161
branch_name = "feat/example"
@@ -173,7 +173,7 @@ For example, this will clone into the `~/projects/coder/coder-dev` folder:
173173
module "git-clone" {
174174
count = data.coder_workspace.me.start_count
175175
source = "registry.coder.com/coder/git-clone/coder"
176-
version = "1.1.2"
176+
version = "1.2.0"
177177
agent_id = coder_agent.example.id
178178
url = "https://github.com/coder/coder"
179179
folder_name = "coder-dev"
@@ -192,9 +192,32 @@ If not defined, the default, `0`, performs a full clone.
192192
module "git-clone" {
193193
count = data.coder_workspace.me.start_count
194194
source = "registry.coder.com/modules/git-clone/coder"
195-
version = "1.1.0"
195+
version = "1.2.0"
196196
agent_id = coder_agent.example.id
197197
url = "https://github.com/coder/coder"
198198
depth = 1
199199
}
200200
```
201+
202+
## Post-clone script
203+
204+
Run a custom script after cloning the repository by setting the `post_clone_script` variable.
205+
This is useful for running initialization tasks like installing dependencies or setting up the environment.
206+
207+
```tf
208+
module "git-clone" {
209+
count = data.coder_workspace.me.start_count
210+
source = "registry.coder.com/coder/git-clone/coder"
211+
version = "1.2.0"
212+
agent_id = coder_agent.example.id
213+
url = "https://github.com/coder/coder"
214+
post_clone_script = <<-EOT
215+
#!/bin/bash
216+
echo "Repository cloned successfully!"
217+
# Install dependencies
218+
npm install
219+
# Run any other initialization tasks
220+
make setup
221+
EOT
222+
}
223+
```

registry/coder/modules/git-clone/main.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ describe("git-clone", async () => {
3030
url: "fake-url",
3131
});
3232
const output = await executeScriptInContainer(state, "alpine/git");
33-
expect(output.exitCode).toBe(128);
3433
expect(output.stdout).toEqual([
3534
"Creating directory ~/fake-url...",
3635
"Cloning fake-url to ~/fake-url...",
3736
]);
37+
expect(output.stderr.join(" ")).toContain("fatal");
38+
expect(output.stderr.join(" ")).toContain("fake-url");
3839
});
3940

4041
it("repo_dir should match repo name for https", async () => {
@@ -244,4 +245,20 @@ describe("git-clone", async () => {
244245
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
245246
]);
246247
});
248+
249+
it("runs post-clone script", async () => {
250+
const state = await runTerraformApply(import.meta.dir, {
251+
agent_id: "foo",
252+
url: "fake-url",
253+
post_clone_script: "echo 'Post-clone script executed'",
254+
});
255+
const output = await executeScriptInContainer(
256+
state,
257+
"alpine/git",
258+
"sh",
259+
"mkdir -p ~/fake-url && echo 'existing' > ~/fake-url/file.txt",
260+
);
261+
expect(output.stdout).toContain("Running post-clone script...");
262+
expect(output.stdout).toContain("Post-clone script executed");
263+
});
247264
});

registry/coder/modules/git-clone/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ variable "depth" {
6262
default = 0
6363
}
6464

65+
variable "post_clone_script" {
66+
description = "Custom script to run after cloning the repository. Runs always after git clone, even if the repository already exists."
67+
type = string
68+
default = null
69+
}
70+
6571
locals {
6672
# Remove query parameters and fragments from the URL
6773
url = replace(replace(var.url, "/\\?.*/", ""), "/#.*/", "")
@@ -81,6 +87,8 @@ locals {
8187
clone_path = var.base_dir != "" ? join("/", [var.base_dir, local.folder_name]) : join("/", ["~", local.folder_name])
8288
# Construct the web URL
8389
web_url = startswith(local.clone_url, "git@") ? replace(replace(local.clone_url, ":", "/"), "git@", "https://") : local.clone_url
90+
# Encode the post_clone_script for passing to the shell script
91+
encoded_post_clone_script = var.post_clone_script != null ? base64encode(var.post_clone_script) : ""
8492
}
8593

8694
output "repo_dir" {
@@ -120,6 +128,7 @@ resource "coder_script" "git_clone" {
120128
REPO_URL : local.clone_url,
121129
BRANCH_NAME : local.branch_name,
122130
DEPTH = var.depth,
131+
POST_CLONE_SCRIPT : local.encoded_post_clone_script,
123132
})
124133
display_name = "Git Clone"
125134
icon = "/icon/git.svg"

registry/coder/modules/git-clone/run.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ BRANCH_NAME="${BRANCH_NAME}"
66
# Expand home if it's specified!
77
CLONE_PATH="$${CLONE_PATH/#\~/$${HOME}}"
88
DEPTH="${DEPTH}"
9+
POST_CLONE_SCRIPT="${POST_CLONE_SCRIPT}"
910

1011
# Check if the variable is empty...
1112
if [ -z "$REPO_URL" ]; then
@@ -52,5 +53,14 @@ if [ -z "$(ls -A "$CLONE_PATH")" ]; then
5253
fi
5354
else
5455
echo "$CLONE_PATH already exists and isn't empty, skipping clone!"
55-
exit 0
56+
fi
57+
58+
# Run post-clone script if provided
59+
if [ -n "$POST_CLONE_SCRIPT" ]; then
60+
echo "Running post-clone script..."
61+
echo "$POST_CLONE_SCRIPT" | base64 -d > /tmp/post_clone.sh
62+
chmod +x /tmp/post_clone.sh
63+
cd "$CLONE_PATH"
64+
/tmp/post_clone.sh
65+
rm /tmp/post_clone.sh
5666
fi

registry/coder/modules/goose/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run the [Goose](https://block.github.io/goose/) agent in your workspace to gener
1313
```tf
1414
module "goose" {
1515
source = "registry.coder.com/coder/goose/coder"
16-
version = "2.2.0"
16+
version = "2.2.1"
1717
agent_id = coder_agent.example.id
1818
folder = "/home/coder"
1919
install_goose = true
@@ -79,7 +79,7 @@ resource "coder_agent" "main" {
7979
module "goose" {
8080
count = data.coder_workspace.me.start_count
8181
source = "registry.coder.com/coder/goose/coder"
82-
version = "2.2.0"
82+
version = "2.2.1"
8383
agent_id = coder_agent.example.id
8484
folder = "/home/coder"
8585
install_goose = true

registry/coder/modules/goose/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ EOT
135135
install_script = file("${path.module}/scripts/install.sh")
136136
start_script = file("${path.module}/scripts/start.sh")
137137
module_dir_name = ".goose-module"
138+
folder = trimsuffix(var.folder, "/")
138139
}
139140

140141
module "agentapi" {
@@ -156,6 +157,7 @@ module "agentapi" {
156157
pre_install_script = var.pre_install_script
157158
post_install_script = var.post_install_script
158159
start_script = local.start_script
160+
folder = local.folder
159161
install_script = <<-EOT
160162
#!/bin/bash
161163
set -o errexit

0 commit comments

Comments
 (0)