|
|
@ -14,9 +14,9 @@ variable "url" {
|
|
|
|
type = string
|
|
|
|
type = string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
variable "path" {
|
|
|
|
variable "base_dir" {
|
|
|
|
default = ""
|
|
|
|
default = ""
|
|
|
|
description = "The path to clone the repository. Defaults to \"$HOME/<basename of url>\"."
|
|
|
|
description = "The base directory to clone the repository. Defaults to \"$HOME\"."
|
|
|
|
type = string
|
|
|
|
type = string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -25,10 +25,19 @@ variable "agent_id" {
|
|
|
|
type = string
|
|
|
|
type = string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locals {
|
|
|
|
|
|
|
|
clone_path = var.base_dir != "" ? join("/", [var.base_dir, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output "repo_dir" {
|
|
|
|
|
|
|
|
value = local.clone_path
|
|
|
|
|
|
|
|
description = "Full path of cloned repo directory"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resource "coder_script" "git_clone" {
|
|
|
|
resource "coder_script" "git_clone" {
|
|
|
|
agent_id = var.agent_id
|
|
|
|
agent_id = var.agent_id
|
|
|
|
script = templatefile("${path.module}/run.sh", {
|
|
|
|
script = templatefile("${path.module}/run.sh", {
|
|
|
|
CLONE_PATH = var.path != "" ? join("/", [var.path, replace(basename(var.url), ".git", "")]) : join("/", ["~", replace(basename(var.url), ".git", "")])
|
|
|
|
CLONE_PATH = local.clone_path
|
|
|
|
REPO_URL : var.url,
|
|
|
|
REPO_URL : var.url,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
display_name = "Git Clone"
|
|
|
|
display_name = "Git Clone"
|
|
|
|