diff --git a/helper/schema/grpc_provider.go b/helper/schema/grpc_provider.go index cc4a9ec445..d9c824d26d 100644 --- a/helper/schema/grpc_provider.go +++ b/helper/schema/grpc_provider.go @@ -796,7 +796,6 @@ func (s *GRPCProviderServer) PlanResourceChange(ctx context.Context, req *tfprot newExtra := map[string]interface{}{} for k, v := range diff.Attributes { - log.Printf("[TRACE] tpg-7934: copying over attribute %q", k) if v.NewExtra != nil { newExtra[k] = v.NewExtra } diff --git a/helper/schema/resource_diff.go b/helper/schema/resource_diff.go index 521c58768d..984929df7b 100644 --- a/helper/schema/resource_diff.go +++ b/helper/schema/resource_diff.go @@ -3,7 +3,6 @@ package schema import ( "errors" "fmt" - "log" "reflect" "strings" "sync" @@ -462,11 +461,9 @@ func (d *ResourceDiff) getChange(key string) (getResult, getResult, bool) { var new getResult for p := range d.updatedKeys { if childAddrOf(key, p) { - log.Printf("[TRACE] tpg-7934: key %q is child of parent %q, counts as computed", key, p) new = d.getExact(strings.Split(key, "."), "newDiff") return old, new, true } - log.Printf("[TRACE] tpg-7934: key %q is not child of parent %q, does not count as computed", key, p) } new = d.get(strings.Split(key, "."), "newDiff") return old, new, false diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 2254cac4a6..7146bef766 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -360,7 +360,6 @@ func (s *Schema) ZeroValue() interface{} { func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *terraform.ResourceAttrDiff { if d == nil { - log.Println("[TRACE] tpg-7934: returning nil from finalizeDiff because nil was passed in") return d } @@ -409,7 +408,7 @@ func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *t if d.Old != "" && d.New == "" { // This is a computed value with an old value set already, // just let it go. - log.Println("[TRACE] tpg-7934: returning nil from finalizeDiff because customized") + log.Println("[DEBUG] A computed value with the empty string as the new value and a non-empty old value was found. Interpreting the empty string as \"unset\" to align with legacy behavior.") return nil } } @@ -1063,13 +1062,18 @@ func (m schemaMap) diffList( oldStr = "" } - diff.Attributes[k+".#"] = countSchema.finalizeDiff( + finalizedAttr := countSchema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: oldStr, New: newStr, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[k+".#"] = finalizedAttr + } else { + delete(diff.Attributes, k+".#") + } } // Figure out the maximum @@ -1169,13 +1173,18 @@ func (m schemaMap) diffMap( oldStr = "" } - diff.Attributes[k+".%"] = countSchema.finalizeDiff( + finalizedAttr := countSchema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: oldStr, New: newStr, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[k+".%"] = finalizedAttr + } else { + delete(diff.Attributes, k+".%") + } } // If the new map is nil and we're computed, then ignore it. @@ -1192,22 +1201,28 @@ func (m schemaMap) diffMap( continue } - diff.Attributes[prefix+k] = schema.finalizeDiff( + finalizedAttr := schema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: old, New: v, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[prefix+k] = finalizedAttr + } } for k, v := range stateMap { - diff.Attributes[prefix+k] = schema.finalizeDiff( + finalizedAttr := schema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: v, NewRemoved: true, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[prefix+k] = finalizedAttr + } } return nil @@ -1279,26 +1294,32 @@ func (m schemaMap) diffSet( countStr = "" } - diff.Attributes[k+".#"] = countSchema.finalizeDiff( + finalizedAttr := countSchema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: countStr, NewComputed: true, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[k+".#"] = finalizedAttr + } return nil } // If the counts are not the same, then record that diff changed := oldLen != newLen if changed || all { - diff.Attributes[k+".#"] = countSchema.finalizeDiff( + finalizedAttr := countSchema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: oldStr, New: newStr, }, customized, ) + if finalizedAttr != nil { + diff.Attributes[k+".#"] = finalizedAttr + } } // Build the list of codes that will make up our set. This is the @@ -1385,8 +1406,7 @@ func (m schemaMap) diffString( return nil } - log.Printf("[TRACE] tpg-7934: setting attribute %q", k) - diff.Attributes[k] = schema.finalizeDiff( + finalizedAttr := schema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: os, New: ns, @@ -1396,6 +1416,9 @@ func (m schemaMap) diffString( }, customized, ) + if finalizedAttr != nil { + diff.Attributes[k] = finalizedAttr + } return nil }