Skip to content

Commit

Permalink
feat: support depth URL argument in Terragrunt modules (#21494)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
  • Loading branch information
emil2k and secustor committed Apr 18, 2023
1 parent 91812d0 commit 288ad1f
Show file tree
Hide file tree
Showing 6 changed files with 828 additions and 179 deletions.
6 changes: 3 additions & 3 deletions lib/modules/manager/terragrunt/__fixtures__/2.hcl
Expand Up @@ -33,9 +33,9 @@ terraform {
source = "github.com/hashicorp/example?ref=next"
}

#hostname
#IP
terraform {
source = "https://104.196.242.174"example?ref=next"
source = "https://104.196.242.174/example?ref=next"
}

#local hostname
Expand Down Expand Up @@ -63,7 +63,7 @@ terraform {
source = "my.host.local/sources/example?ref=v1.2.1"
}

#ip
#hostname
terraform {
source = "my.host/example?ref=next"
}
Expand Down
166 changes: 166 additions & 0 deletions lib/modules/manager/terragrunt/__fixtures__/3.hcl
@@ -0,0 +1,166 @@
#real
terraform {
extra_arguments "common_vars" {
commands = ["plan", "apply"]

arguments = [
"-var-file=../../common.tfvars",
"-var-file=../region.tfvars"
]
}

before_hook "before_hook" {
commands = ["apply", "plan"]
execute = ["echo", "Running Terraform"]
}

source = "github.com/myuser/myrepo//folder/modules/moduleone?ref=v0.0.9&depth=1"

after_hook "after_hook" {
commands = ["apply", "plan"]
execute = ["echo", "Finished running Terraform"]
run_on_error = true
}
}

#foo
terraform {
source = "github.com/hashicorp/example?ref=v1.0.0&depth=1"
}

#bar
terraform {
source = "github.com/hashicorp/example?ref=next&depth=3"
}

#IP
terraform {
source = "https://104.196.242.174/example?ref=next&depth=1"
}

#local hostname
terraform {
source = "my.host.local/example?ref=v1.2.1&depth=1"
}

#local hostname
terraform {
source = "my.host/modules/test"
}

#local hostname
terraform {
source = "my.host/modules/test?ref=v1.2.1&depth=1"
}

#local hostname
terraform {
source = "my.host"
}

#local hostname
terraform {
source = "my.host.local/sources/example?ref=v1.2.1&depth=1"
}

#hostname
terraform {
source = "my.host/example?ref=next&depth=1"
}

#invalid
terraform {
source = "//terraform/module/test?ref=next&depth=1"
}

#repo-with-non-semver-ref
terraform {
source = "github.com/githubuser/myrepo//terraform/modules/moduleone?ref=tfmodule_one-v0.0.9&depth=1"
}

#repo-with-dot
terraform {
source = "github.com/hashicorp/example.2.3?ref=v1.0.0&depth=1"
}

#repo-with-dot-and-git-suffix
terraform {
source = "github.com/hashicorp/example.2.3.git?ref=v1.0.0&depth=1"
}

#source without pinning
terraform {
source = "hashicorp/consul/aws"
}

# source with double-slash
terraform {
source = "github.com/tieto-cem/terraform-aws-ecs-task-definition//modules/container-definition?ref=v0.1.0&depth=1"
}

# regular sources
terraform {
source = "github.com/tieto-cem/terraform-aws-ecs-task-definition?ref=v0.1.0&depth=1"
}

terraform {
source = "git@github.com:hashicorp/example.git?ref=v2.0.0&depth=1"
}

terraform {
source = "terraform-aws-modules/security-group/aws//modules/http-80"

}

terraform {
source = "terraform-aws-modules/security-group/aws"
}

terraform {
source = "../../terraforms/fe"
}

# nosource, ignored by test since it does not have source on the next line
terraform {
foo = "bar"
}

# foobar
terraform {
source = "https://bitbucket.com/hashicorp/example?ref=v1.0.0&depth=1"
}

# gittags
terraform {
source = "git::https://bitbucket.com/hashicorp/example?ref=v1.0.0&depth=1"
}

# gittags_badversion
terraform {
source = "git::https://bitbucket.com/hashicorp/example?ref=next&depth=1"
}

# gittags_subdir
terraform {
source = "git::https://bitbucket.com/hashicorp/example//subdir/test?ref=v1.0.1&depth=1"
}

# gittags_http
terraform {
source = "git::http://bitbucket.com/hashicorp/example?ref=v1.0.2&depth=1"
}

# gittags_ssh
terraform {
source = "git::ssh://git@bitbucket.com/hashicorp/example?ref=v1.0.3&depth=1"
}

# invalid, ignored by test since it does not have source on the next line
terraform {
}

# unsupported terragrunt, ignored by test since it does not have source on the next line
terraform {
name = "foo"
dummy = "true"
}
166 changes: 166 additions & 0 deletions lib/modules/manager/terragrunt/__fixtures__/4.hcl
@@ -0,0 +1,166 @@
#real
terraform {
extra_arguments "common_vars" {
commands = ["plan", "apply"]

arguments = [
"-var-file=../../common.tfvars",
"-var-file=../region.tfvars"
]
}

before_hook "before_hook" {
commands = ["apply", "plan"]
execute = ["echo", "Running Terraform"]
}

source = "github.com/myuser/myrepo//folder/modules/moduleone?depth=1&ref=v0.0.9"

after_hook "after_hook" {
commands = ["apply", "plan"]
execute = ["echo", "Finished running Terraform"]
run_on_error = true
}
}

#foo
terraform {
source = "github.com/hashicorp/example?depth=5&ref=v1.0.0"
}

#bar
terraform {
source = "github.com/hashicorp/example?depth=1&ref=next"
}

#IP
terraform {
source = "https://104.196.242.174/example?depth=1&ref=next"
}

#local hostname
terraform {
source = "my.host.local/example?depth=1&ref=v1.2.1"
}

#local hostname
terraform {
source = "my.host/modules/test"
}

#local hostname
terraform {
source = "my.host/modules/test?depth=1&ref=v1.2.1"
}

#local hostname
terraform {
source = "my.host"
}

#local hostname
terraform {
source = "my.host.local/sources/example?depth=1&ref=v1.2.1"
}

#hostname
terraform {
source = "my.host/example?depth=1&ref=next"
}

#invalid
terraform {
source = "//terraform/module/test?depth=1&ref=next"
}

#repo-with-non-semver-ref
terraform {
source = "github.com/githubuser/myrepo//terraform/modules/moduleone?depth=1&ref=tfmodule_one-v0.0.9"
}

#repo-with-dot
terraform {
source = "github.com/hashicorp/example.2.3?depth=1&ref=v1.0.0"
}

#repo-with-dot-and-git-suffix
terraform {
source = "github.com/hashicorp/example.2.3.git?depth=1&ref=v1.0.0"
}

#source without pinning
terraform {
source = "hashicorp/consul/aws"
}

# source with double-slash
terraform {
source = "github.com/tieto-cem/terraform-aws-ecs-task-definition//modules/container-definition?depth=1&ref=v0.1.0"
}

# regular sources
terraform {
source = "github.com/tieto-cem/terraform-aws-ecs-task-definition?depth=1&ref=v0.1.0"
}

terraform {
source = "git@github.com:hashicorp/example.git?depth=1&ref=v2.0.0"
}

terraform {
source = "terraform-aws-modules/security-group/aws//modules/http-80"

}

terraform {
source = "terraform-aws-modules/security-group/aws"
}

terraform {
source = "../../terraforms/fe"
}

# nosource, ignored by test since it does not have source on the next line
terraform {
foo = "bar"
}

# foobar
terraform {
source = "https://bitbucket.com/hashicorp/example?depth=1&ref=v1.0.0"
}

# gittags
terraform {
source = "git::https://bitbucket.com/hashicorp/example?depth=1&ref=v1.0.0"
}

# gittags_badversion
terraform {
source = "git::https://bitbucket.com/hashicorp/example?depth=1&ref=next"
}

# gittags_subdir
terraform {
source = "git::https://bitbucket.com/hashicorp/example//subdir/test?depth=1&ref=v1.0.1"
}

# gittags_http
terraform {
source = "git::http://bitbucket.com/hashicorp/example?depth=1&ref=v1.0.2"
}

# gittags_ssh
terraform {
source = "git::ssh://git@bitbucket.com/hashicorp/example?depth=1&ref=v1.0.3"
}

# invalid, ignored by test since it does not have source on the next line
terraform {
}

# unsupported terragrunt, ignored by test since it does not have source on the next line
terraform {
name = "foo"
dummy = "true"
}

0 comments on commit 288ad1f

Please sign in to comment.