Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configs: A test for the regression reported in #31081
5417975 addressed a regression in the logic for catching when the newer module meta-arguments are used in conjunction with the legacy practice of including provider configurations inside modules, where the check started incorrectly catching situations where the legacy nested provider configuration was in the same module as the child call using one of those meta-arguments. This is a regression test to catch if a similar bug arises in the future. Since it's testing validation rules that apply to an entire configuration tree, it ended up in a rather idiosyncratic location under the "configload" package, rather than directly in "configs". The "configs" package only knows how to load one module at a time, so it's harder to write a test like this in that context. Due to it being further removed from the code it is testing, I included a test for the correct error too in order to increase the chance that we'll learn if future changes in the "configs" package invalidate this regression test. I've verified that this new test fails without the change made in the earlier commit.
- Loading branch information
1 parent
be7f46a
commit ec421fe
Showing
9 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...al/configs/configload/testdata/child-provider-child-count/.terraform/modules/modules.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"Modules": [ | ||
{ | ||
"Key": "", | ||
"Source": "", | ||
"Dir": "." | ||
}, | ||
{ | ||
"Key": "child", | ||
"Source": "./child", | ||
"Dir": "testdata/child-provider-child-count/child" | ||
}, | ||
{ | ||
"Key": "child.grandchild", | ||
"Source": "../grandchild", | ||
"Dir": "testdata/child-provider-child-count/grandchild" | ||
} | ||
] | ||
} |
4 changes: 4 additions & 0 deletions
4
...rnal/configs/configload/testdata/child-provider-child-count/child-provider-child-count.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module "child" { | ||
source = "./child" | ||
count = 1 | ||
} |
7 changes: 7 additions & 0 deletions
7
.../configload/testdata/child-provider-child-count/child/child-provider-child-count-child.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
provider "boop" { | ||
blah = true | ||
} | ||
|
||
module "grandchild" { | ||
source = "../grandchild" | ||
} |
1 change: 1 addition & 0 deletions
1
...d/testdata/child-provider-child-count/grandchild/child-provider-child-count-grandchild.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Intentionally blank |
19 changes: 19 additions & 0 deletions
19
...nfigs/configload/testdata/child-provider-grandchild-count/.terraform/modules/modules.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"Modules": [ | ||
{ | ||
"Key": "", | ||
"Source": "", | ||
"Dir": "." | ||
}, | ||
{ | ||
"Key": "child", | ||
"Source": "./child", | ||
"Dir": "testdata/child-provider-grandchild-count/child" | ||
}, | ||
{ | ||
"Key": "child.grandchild", | ||
"Source": "../grandchild", | ||
"Dir": "testdata/child-provider-grandchild-count/grandchild" | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...gs/configload/testdata/child-provider-grandchild-count/child-provider-grandchild-count.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module "child" { | ||
source = "./child" | ||
} |
12 changes: 12 additions & 0 deletions
12
...d/testdata/child-provider-grandchild-count/child/child-provider-grandchild-count-child.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
provider "boop" { | ||
blah = true | ||
} | ||
|
||
module "grandchild" { | ||
source = "../grandchild" | ||
|
||
# grandchild's caller (this file) has a legacy nested provider block, but | ||
# grandchild itself does not and so it's valid to use "count" here even | ||
# though it wouldn't be valid to call "child" (this file) with "count". | ||
count = 2 | ||
} |
1 change: 1 addition & 0 deletions
1
.../child-provider-grandchild-count/grandchild/child-provider-grandchild-count-grandchild.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Intentionally blank |