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
|
config *configs.Config
|
||||||
changes *plans.Changes
|
changes *plans.Changes
|
||||||
state *states.State
|
state *states.State
|
||||||
|
refreshState *states.State
|
||||||
targets []addrs.Targetable
|
targets []addrs.Targetable
|
||||||
variables InputValues
|
variables InputValues
|
||||||
meta *ContextMeta
|
meta *ContextMeta
|
||||||
|
@ -231,6 +232,7 @@ func NewContext(opts *ContextOpts) (*Context, tfdiags.Diagnostics) {
|
||||||
meta: opts.Meta,
|
meta: opts.Meta,
|
||||||
config: config,
|
config: config,
|
||||||
state: state,
|
state: state,
|
||||||
|
refreshState: state.DeepCopy(),
|
||||||
targets: opts.Targets,
|
targets: opts.Targets,
|
||||||
uiInput: opts.UIInput,
|
uiInput: opts.UIInput,
|
||||||
variables: variables,
|
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
|
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
|
// The execution plan encapsulates the context and can be stored
|
||||||
// in order to reinstantiate a context later for Apply.
|
// 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.Changes = c.changes
|
||||||
|
|
||||||
|
p.State = c.refreshState
|
||||||
|
|
||||||
return p, diags
|
return p, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,8 +801,7 @@ func (c *Context) graphWalker(operation walkOperation) *ContextGraphWalker {
|
||||||
|
|
||||||
case walkPlan:
|
case walkPlan:
|
||||||
state = c.state.SyncWrapper()
|
state = c.state.SyncWrapper()
|
||||||
// plan requires a second state to store the refreshed resources
|
refreshState = c.refreshState.SyncWrapper()
|
||||||
refreshState = c.state.DeepCopy().SyncWrapper()
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state = c.state.SyncWrapper()
|
state = c.state.SyncWrapper()
|
||||||
|
|
Loading…
Reference in New Issue