core: Properly handle no-op changes in plan
Previously we just left these out of the plan altogether, but in the new plan types we intentionally include change information for every resource instance, even if no changes are actually planned, to allow alternative plan file viewers to show what isn't changing as well as what is.
This commit is contained in:
parent
2f0e5d93c8
commit
a7342de274
|
@ -91,6 +91,8 @@ func NewPlan(changes *plans.Changes) *Plan {
|
|||
}
|
||||
|
||||
switch rc.Action {
|
||||
case plans.NoOp:
|
||||
continue
|
||||
case plans.Create:
|
||||
if dataSource {
|
||||
// Use "refresh" as the action for display, but core
|
||||
|
|
|
@ -386,6 +386,15 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
if diff == nil {
|
||||
// schema.Provider.Diff returns nil if it ends up making a diff with
|
||||
// no changes, but our new interface wants us to return an actual
|
||||
// change description that _shows_ there are no changes, so we need
|
||||
// to synthesize one here.
|
||||
resp.PlannedState = req.PriorState
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// now we need to apply the diff to the prior state, so get the planned state
|
||||
plannedStateVal, err := schema.ApplyDiff(priorStateVal, diff, block)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/terraform/plugin/convert"
|
||||
"github.com/hashicorp/terraform/plugin/proto"
|
||||
|
@ -398,13 +400,16 @@ func (p *GRPCProvider) ApplyResourceChange(r providers.ApplyResourceChangeReques
|
|||
|
||||
resp.Private = protoResp.Private
|
||||
|
||||
if protoResp.NewState != nil {
|
||||
state, err := msgpack.Unmarshal(protoResp.NewState.Msgpack, resSchema.Block.ImpliedType())
|
||||
if err != nil {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(err)
|
||||
return resp
|
||||
}
|
||||
|
||||
resp.NewState = state
|
||||
} else {
|
||||
resp.NewState = cty.NullVal(resSchema.Block.ImpliedType())
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ func (t *DiffTransformer) Transform(g *Graph) error {
|
|||
// other actions.
|
||||
var update, delete bool
|
||||
switch rc.Action {
|
||||
case plans.NoOp:
|
||||
continue
|
||||
case plans.Delete:
|
||||
delete = true
|
||||
case plans.Replace:
|
||||
|
|
Loading…
Reference in New Issue