pot*_*ato 5 git terraform terragrunt
我最近开始使用 terragrunt 并且一直想知道是否可以从特定分支而不是特定标签(或除了标签)而不是默认的 master 下载模块
从master下载特定标签:
terraform {
source = "git@github.com:<repo>/infrastructure-modules.git//gcp/bucket?ref=v.0.0.1"
}
Run Code Online (Sandbox Code Playgroud)
从存储库下载特定分支?
# Pseudo code
terraform {
source = "git@github.com:<repo>/infrastructure-modules.git//gcp/bucket?ref=v.0.0.1%branch=test"
}
Run Code Online (Sandbox Code Playgroud)
我能够使用以下命令指定分支:
terraform {
source = "git@github.com:<repo>/infrastructure-modules.git//gcp/bucket?ref=branch-name"
}
Run Code Online (Sandbox Code Playgroud)
查看 terragruntcli/download_source_test.go源代码,没有明显的方法来指定分支。
这意味着您需要向该分支添加一个标签,并将该标签用作ref.
话虽如此,首先检查是否ref=<mybranch>有效。
然而,OPpotatopotato在评论中确认直接引用分支名称是行不通的。
我刚刚在分支上进行了更改,并且:
Run Code Online (Sandbox Code Playgroud)git add git commit git tag -a 'v1.branch' git push --follow-tags -u origin <branch_name>我可以使用对分支的标记引用,而不是
master.
德国Dautin的答案指向Terraform/模块源/选择修订版。
默认情况下,Terraform 将克隆并使用所选存储库中的默认分支(由 HEAD 引用)。您可以使用 ref 参数覆盖它:
Run Code Online (Sandbox Code Playgroud)git add git commit git tag -a 'v1.branch' git push --follow-tags -u origin <branch_name>ref 参数的值可以是 git checkout 命令接受的任何引用,包括分支和标记名称。
因此可以使用分支名称。
| 归档时间: |
|
| 查看次数: |
8150 次 |
| 最近记录: |