Merge pull request #20624 from hashicorp/jbardin/revert

revert #20595
This commit is contained in:
James Bardin 2019-03-08 21:07:47 -05:00 committed by GitHub
commit dc154cf242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -127,6 +127,16 @@ func ResourceChange(
panic(fmt.Sprintf("failed to decode plan for %s while rendering diff: %s", addr, err))
}
// We currently have an opt-out that permits the legacy SDK to return values
// that defy our usual conventions around handling of nesting blocks. To
// avoid the rendering code from needing to handle all of these, we'll
// normalize first.
// (Ideally we'd do this as part of the SDK opt-out implementation in core,
// but we've added it here for now to reduce risk of unexpected impacts
// on other code in core.)
changeV.Change.Before = objchange.NormalizeObjectFromLegacySDK(changeV.Change.Before, schema)
changeV.Change.After = objchange.NormalizeObjectFromLegacySDK(changeV.Change.After, schema)
bodyWritten := p.writeBlockBodyDiff(schema, changeV.Before, changeV.After, 6, path)
if bodyWritten {
buf.WriteString("\n")

View File

@ -9,8 +9,6 @@ import (
"strconv"
"strings"
"github.com/hashicorp/terraform/plans/objchange"
"github.com/zclconf/go-cty/cty"
ctyconvert "github.com/zclconf/go-cty/cty/convert"
"github.com/zclconf/go-cty/cty/msgpack"
@ -460,7 +458,6 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso
}
newStateVal = copyTimeoutValues(newStateVal, stateVal)
newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block)
newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType())
if err != nil {
@ -597,7 +594,6 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl
}
plannedStateVal = copyTimeoutValues(plannedStateVal, proposedNewStateVal)
plannedStateVal = objchange.NormalizeObjectFromLegacySDK(plannedStateVal, block)
// The old SDK code has some imprecisions that cause it to sometimes
// generate differences that the SDK itself does not consider significant
@ -836,7 +832,6 @@ func (s *GRPCProviderServer) ApplyResourceChange(_ context.Context, req *proto.A
newStateVal = normalizeNullValues(newStateVal, plannedStateVal, false)
newStateVal = copyTimeoutValues(newStateVal, plannedStateVal)
newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block)
newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType())
if err != nil {
@ -960,7 +955,6 @@ func (s *GRPCProviderServer) ReadDataSource(_ context.Context, req *proto.ReadDa
}
newStateVal = copyTimeoutValues(newStateVal, configVal)
newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block)
newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType())
if err != nil {