core: Only treat instance ref as resource ref if instance nonexistent
We previously added a special case for dealing with references to instances in the plan graph where there are only resource nodes. However, this was too general a fix and so it upset the handling of graphs where instances _are_ present. Now we'll do that fallback behavior only if there is no instance node in the graph already, so the exact matching behavior will be used in graphs where the instances are present.
This commit is contained in:
parent
68c8d83620
commit
b6d0abef1d
|
@ -204,14 +204,18 @@ func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []addrs.Reference
|
|||
for _, ref := range rn.References() {
|
||||
subject := ref.Subject
|
||||
|
||||
// References may point to specific instances, but the resources may
|
||||
// not yet be expanded. Make sure we reference the resource type
|
||||
// itself.
|
||||
key := m.referenceMapKey(v, subject)
|
||||
if _, exists := m.vertices[key]; !exists {
|
||||
// If what we were looking for was a ResourceInstance then we
|
||||
// might be in a resource-oriented graph rather than an
|
||||
// instance-oriented graph, and so we'll see if we have the
|
||||
// resource itself instead.
|
||||
if ri, ok := subject.(addrs.ResourceInstance); ok {
|
||||
subject = ri.Resource
|
||||
key = m.referenceMapKey(v, subject)
|
||||
}
|
||||
}
|
||||
|
||||
key := m.referenceMapKey(v, subject)
|
||||
vertices := m.vertices[key]
|
||||
for _, rv := range vertices {
|
||||
// don't include self-references
|
||||
|
|
Loading…
Reference in New Issue