From fd34def9dc4c5fcd5b9bc58d8a0a7f1e1e2b7c53 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Fri, 22 Nov 2019 15:12:26 -0500 Subject: [PATCH] More comment updates, a lil refactor --- states/module.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/states/module.go b/states/module.go index 8f1596381..152f37500 100644 --- a/states/module.go +++ b/states/module.go @@ -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 }