data.git
The git data provider clones a git repository
to a specific directory
Opening the existing repository
data "git" "this" {
url = "."
}
Cloning a new repository
togomak {
version = 2
}
data "git" "repo" {
url = "https://github.com/srevinsaju/togomak"
branch = "v1"
files = ["togomak.hcl"]
}
stage "example" {
name = "example"
script = <<-EOT
echo '${data.git.repo.files["togomak.hcl"]}'
EOT
}
Reusing remote stages, using togomak
togomak {
version = 2
}
data "git" "eva01_source" {
url = "https://github.com/srevinsaju/togomak"
files = ["togomak.hcl"]
}
macro "gendo_brain" {
files = data.git.eva01_source.files
}
stage "build_eva01" {
name = "Building eva unit"
use {
macro = macro.gendo_brain
}
}
Arguments Reference
url- The URL of the repository to clone.tag- The tag to checkout.tagtakes precedence overbranch.ref- The reference to checkout, in the formatrefs/tags/v3for example.reftakes precedence overtagandbranch.branch- The branch to checkout.refandtagtakes precedence overbranch.destination- The destination directory to clone the repository to, defaults to"memory", which clones into a temporary directory managed bytogomakcommit- The commit to checkout.depth- The depth of the clone.ca_bundle- The path to a CA bundle file or directory, (deprecated, does nothing).auth- The authentication credentials to use when cloning the repository. Structure documented belowfiles- The files to checkout from the repository. Accepts an array of file paths.
Attributes Reference
last_tag- The latest tag in the repository, defaults to""commits_since_last_tag- The number of commits since the last tag, defaults to0sha- The SHA of the commit, defaults to""ref- The ref of the commit, in the formatrefs/heads/<branch>orrefs/tags/<tag>, defaults to""is_tag- Whether the ref is a tag, defaults tofalsefiles- The files checked out from the repository. Returns a map, with the keys being the file paths and the values being the file contents.branch- The branch checked out from the repository. Returns a string.destination- The destination where the repository is stored.