From d50a152f8bc09da55508ebc9c16a09586dc3023f Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 19 Oct 2018 14:25:20 -0400 Subject: [PATCH] check for a nil diff in simpleDiff --- helper/schema/resource.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/helper/schema/resource.go b/helper/schema/resource.go index 7d5a44aa7d..a26dfc9f88 100644 --- a/helper/schema/resource.go +++ b/helper/schema/resource.go @@ -320,6 +320,11 @@ func (r *Resource) simpleDiff( return instanceDiff, err } + if instanceDiff == nil { + log.Printf("[DEBUG] Instance Diff is nil in SimpleDiff()") + return nil, err + } + // Make sure the old value is set in each of the instance diffs. // This was done by the RequiresNew logic in the full legacy Diff. for k, attr := range instanceDiff.Attributes { @@ -331,14 +336,9 @@ func (r *Resource) simpleDiff( } } - if instanceDiff != nil { - if err := t.DiffEncode(instanceDiff); err != nil { - log.Printf("[ERR] Error encoding timeout to instance diff: %s", err) - } - } else { - log.Printf("[DEBUG] Instance Diff is nil in Diff()") + if err := t.DiffEncode(instanceDiff); err != nil { + log.Printf("[ERR] Error encoding timeout to instance diff: %s", err) } - return instanceDiff, err }