mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
add DependsOn method to moduleExpandModule
We'll need this again for getting the transitive depends_on references from parent module calls. This is needed to inform us how to handle data sources during refresh and plan.
This commit is contained in:
parent
535267e986
commit
a03c86f612
@ -47,18 +47,7 @@ func (n *nodeExpandModule) References() []*addrs.Reference {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, traversal := range n.ModuleCall.DependsOn {
|
||||
ref, diags := addrs.ParseRef(traversal)
|
||||
if diags.HasErrors() {
|
||||
// We ignore this here, because this isn't a suitable place to return
|
||||
// errors. This situation should be caught and rejected during
|
||||
// validation.
|
||||
log.Printf("[ERROR] Can't parse %#v from depends_on as reference: %s", traversal, diags.Err())
|
||||
continue
|
||||
}
|
||||
|
||||
refs = append(refs, ref)
|
||||
}
|
||||
refs = append(refs, n.DependsOn()...)
|
||||
|
||||
// Expansion only uses the count and for_each expressions, so this
|
||||
// particular graph node only refers to those.
|
||||
@ -82,6 +71,28 @@ func (n *nodeExpandModule) References() []*addrs.Reference {
|
||||
return appendResourceDestroyReferences(refs)
|
||||
}
|
||||
|
||||
func (n *nodeExpandModule) DependsOn() []*addrs.Reference {
|
||||
if n.ModuleCall == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var refs []*addrs.Reference
|
||||
for _, traversal := range n.ModuleCall.DependsOn {
|
||||
ref, diags := addrs.ParseRef(traversal)
|
||||
if diags.HasErrors() {
|
||||
// We ignore this here, because this isn't a suitable place to return
|
||||
// errors. This situation should be caught and rejected during
|
||||
// validation.
|
||||
log.Printf("[ERROR] Can't parse %#v from depends_on as reference: %s", traversal, diags.Err())
|
||||
continue
|
||||
}
|
||||
|
||||
refs = append(refs, ref)
|
||||
}
|
||||
|
||||
return refs
|
||||
}
|
||||
|
||||
// GraphNodeReferenceOutside
|
||||
func (n *nodeExpandModule) ReferenceOutside() (selfPath, referencePath addrs.Module) {
|
||||
return n.Addr, n.Addr.Parent()
|
||||
|
Loading…
Reference in New Issue
Block a user