Merge pull request #25543 from hashicorp/jbardin/prune-root-temps
ensure root module locals and vars are pruned
This commit is contained in:
commit
26fb544e43
|
@ -1,11 +1,19 @@
|
|||
data "test_data_source" "bar" {
|
||||
for_each = {
|
||||
a = "b"
|
||||
}
|
||||
foo = "zing"
|
||||
}
|
||||
|
||||
data "test_data_source" "foo" {
|
||||
for_each = data.test_data_source.bar
|
||||
foo = "ok"
|
||||
}
|
||||
|
||||
locals {
|
||||
l = [
|
||||
{
|
||||
name = data.test_data_source.foo.id
|
||||
name = data.test_data_source.foo["a"].id
|
||||
val = "null"
|
||||
},
|
||||
]
|
||||
|
|
|
@ -252,17 +252,16 @@ func (m *pruneUnusedNodesMod) removeUnused(g *Graph) {
|
|||
// dealing with complex looping and labels
|
||||
func() {
|
||||
n := nodes[i]
|
||||
switch n.(type) {
|
||||
switch n := n.(type) {
|
||||
case graphNodeTemporaryValue:
|
||||
// temporary value, which consist of variables, locals, and
|
||||
// outputs, must be kept if anything refers to them.
|
||||
if n, ok := n.(GraphNodeModulePath); ok {
|
||||
// root outputs always have an implicit dependency on
|
||||
// remote state.
|
||||
if n.ModulePath().IsRoot() {
|
||||
return
|
||||
}
|
||||
// root module outputs indicate they are not temporary by
|
||||
// returning false here.
|
||||
if !n.temporaryValue() {
|
||||
return
|
||||
}
|
||||
|
||||
// temporary values, which consist of variables, locals,
|
||||
// and outputs, must be kept if anything refers to them.
|
||||
for _, v := range g.UpEdges(n) {
|
||||
// keep any value which is connected through a
|
||||
// reference
|
||||
|
|
Loading…
Reference in New Issue