From 3b4382082d71316f1c8e882002ed86ee9ead2081 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Fri, 22 Nov 2019 15:21:55 -0500 Subject: [PATCH] More comments and names --- states/module.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/states/module.go b/states/module.go index 152f37500..a7a09f5a9 100644 --- a/states/module.go +++ b/states/module.go @@ -101,9 +101,9 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R delete(ms.Resources, addr.Resource.String()) return } - // check for an existing resource - inst := rs.Instances[addr.Key] - if inst == nil { + // check for an existing resource, now that we've ensured that rs.Instances is more than 0/not nil + is := rs.Instances[addr.Key] + if is == nil { // if there is no instance, but the resource exists and has other instances, // be chill, just return return @@ -111,8 +111,8 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R // if we have an instance, update the current // TODO: this setting happens below as well, so possibly this can be removed, // but not changing it right now as we might return in the block below - inst.Current = obj - if !inst.HasObjects() { + is.Current = obj + if !is.HasObjects() { // If we have no objects at all then we'll clean up. delete(rs.Instances, addr.Key) if len(rs.Instances) == 0 { @@ -120,6 +120,7 @@ func (ms *Module) SetResourceInstanceCurrent(addr addrs.ResourceInstance, obj *R return } } + // Nothing more to do here, so return! return } if rs == nil && obj != nil {