mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
return the refreshed state in the Plan result
This commit is contained in:
parent
8cef62e455
commit
5cf7e237d5
@ -96,6 +96,7 @@ type Context struct {
|
||||
config *configs.Config
|
||||
changes *plans.Changes
|
||||
state *states.State
|
||||
refreshState *states.State
|
||||
targets []addrs.Targetable
|
||||
variables InputValues
|
||||
meta *ContextMeta
|
||||
@ -231,6 +232,7 @@ func NewContext(opts *ContextOpts) (*Context, tfdiags.Diagnostics) {
|
||||
meta: opts.Meta,
|
||||
config: config,
|
||||
state: state,
|
||||
refreshState: state.DeepCopy(),
|
||||
targets: opts.Targets,
|
||||
uiInput: opts.UIInput,
|
||||
variables: variables,
|
||||
@ -493,7 +495,8 @@ Note that the -target option is not suitable for routine use, and is provided on
|
||||
return c.state, diags
|
||||
}
|
||||
|
||||
// Plan generates an execution plan for the given context.
|
||||
// Plan generates an execution plan for the given context, and returns the
|
||||
// refreshed state.
|
||||
//
|
||||
// The execution plan encapsulates the context and can be stored
|
||||
// in order to reinstantiate a context later for Apply.
|
||||
@ -578,6 +581,8 @@ The -target option is not for routine use, and is provided only for exceptional
|
||||
}
|
||||
p.Changes = c.changes
|
||||
|
||||
p.State = c.refreshState
|
||||
|
||||
return p, diags
|
||||
}
|
||||
|
||||
@ -796,8 +801,7 @@ func (c *Context) graphWalker(operation walkOperation) *ContextGraphWalker {
|
||||
|
||||
case walkPlan:
|
||||
state = c.state.SyncWrapper()
|
||||
// plan requires a second state to store the refreshed resources
|
||||
refreshState = c.state.DeepCopy().SyncWrapper()
|
||||
refreshState = c.refreshState.SyncWrapper()
|
||||
|
||||
default:
|
||||
state = c.state.SyncWrapper()
|
||||
|
Loading…
Reference in New Issue
Block a user