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

Commit 7d31865

Browse files
authored
feat!(git-clone): change path input to base_dir and return repo_dir as output (#132)
1 parent d3fc2d2 commit 7d31865

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

git-clone/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags: [git, helper]
99

1010
# Git Clone
1111

12-
This module allows you to automatically clone a repository by URL and skip if it exists in the path provided.
12+
This module allows you to automatically clone a repository by URL and skip if it exists in the base directory provided.
1313

1414
```hcl
1515
module "git-clone" {
@@ -38,6 +38,6 @@ module "git-clone" {
3838
version = "1.0.0"
3939
agent_id = coder_agent.example.id
4040
url = "https://github.com/coder/coder"
41-
path = "~/projects/coder/coder"
41+
base_dir = "~/projects/coder"
4242
}
4343
```

git-clone/main.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ variable "url" {
1414
type = string
1515
}
1616

17-
variable "path" {
17+
variable "base_dir" {
1818
default = ""
19-
description = "The path to clone the repository. Defaults to \"$HOME/<basename of url>\"."
19+
description = "The base directory to clone the repository. Defaults to \"$HOME\"."
2020
type = string
2121
}
2222

@@ -25,10 +25,19 @@ variable "agent_id" {
2525
type = string
2626
}
2727

28+
locals {
29+
clone_path = var.base_dir != "" ? join("/", [var.base_dir, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
30+
}
31+
32+
output "repo_dir" {
33+
value = local.clone_path
34+
description = "Full path of cloned repo directory"
35+
}
36+
2837
resource "coder_script" "git_clone" {
2938
agent_id = var.agent_id
3039
script = templatefile("${path.module}/run.sh", {
31-
CLONE_PATH = var.path != "" ? join("/", [var.path, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
40+
CLONE_PATH = local.clone_path
3241
REPO_URL : var.url,
3342
})
3443
display_name = "Git Clone"

0 commit comments

Comments
 (0)