mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
json-output: Config-driven move support in JSON UI
Add previous address information to the `planned_change` and `resource_drift` messages for the streaming JSON UI output of plan and apply operations. Here we also add a "move" action value to the `change` object of these messages, to represent a move-only operation. As part of this work we also simplify this code to use the plan's DriftedResources values instead of recomputing the drift from state.
This commit is contained in:
@@ -12,14 +12,22 @@ func NewResourceInstanceChange(change *plans.ResourceInstanceChangeSrc) *Resourc
|
||||
Action: changeAction(change.Action),
|
||||
Reason: changeReason(change.ActionReason),
|
||||
}
|
||||
if !change.Addr.Equal(change.PrevRunAddr) {
|
||||
if c.Action == ActionNoOp {
|
||||
c.Action = ActionMove
|
||||
}
|
||||
pr := newResourceAddr(change.PrevRunAddr)
|
||||
c.PreviousResource = &pr
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type ResourceInstanceChange struct {
|
||||
Resource ResourceAddr `json:"resource"`
|
||||
Action ChangeAction `json:"action"`
|
||||
Reason ChangeReason `json:"reason,omitempty"`
|
||||
Resource ResourceAddr `json:"resource"`
|
||||
PreviousResource *ResourceAddr `json:"previous_resource,omitempty"`
|
||||
Action ChangeAction `json:"action"`
|
||||
Reason ChangeReason `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
func (c *ResourceInstanceChange) String() string {
|
||||
@@ -30,6 +38,7 @@ type ChangeAction string
|
||||
|
||||
const (
|
||||
ActionNoOp ChangeAction = "noop"
|
||||
ActionMove ChangeAction = "move"
|
||||
ActionCreate ChangeAction = "create"
|
||||
ActionRead ChangeAction = "read"
|
||||
ActionUpdate ChangeAction = "update"
|
||||
|
||||
Reference in New Issue
Block a user