More comment updates, a lil refactor

This commit is contained in:
Pam Selle 2019-11-22 15:12:26 -05:00
parent ca9da51516
commit fd34def9dc
1 changed files with 7 additions and 8 deletions

View File

@ -123,22 +123,21 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R
return
}
if rs == nil && obj != nil {
// We don't have have a resource
// make the resource! which happens in setResourceMeta, so okay
// We don't have have a resource so make one, which is a side effect of setResourceMeta
ms.SetResourceMeta(addr.Resource, eachModeForInstanceKey(addr.Key), provider)
// now we have a resource! so update the rs value
// now we have a resource! so update the rs value to point to it
rs = ms.Resource(addr.Resource)
}
// Get our instance from the resource; it could be there or not at this point
inst := rs.Instances[addr.Key]
if inst == nil {
// if we don't have a resource, create one
rs.Instances[addr.Key] = NewResourceInstance()
is := rs.Instances[addr.Key]
if is == nil {
// if we don't have a resource, create one and add to the instances
is = NewResourceInstance()
rs.Instances[addr.Key] = is
// update the resource meta because we have a new instance, so EachMode may have changed
ms.SetResourceMeta(addr.Resource, eachModeForInstanceKey(addr.Key), provider)
}
is := rs.EnsureInstance(addr.Key)
is.Current = obj
}