return the refreshed state in the Plan result
This commit is contained in:
parent
8cef62e455
commit
5cf7e237d5
|
@ -93,13 +93,14 @@ type ContextMeta struct {
|
||||||
// perform operations on infrastructure. This structure is built using
|
// perform operations on infrastructure. This structure is built using
|
||||||
// NewContext.
|
// NewContext.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
config *configs.Config
|
config *configs.Config
|
||||||
changes *plans.Changes
|
changes *plans.Changes
|
||||||
state *states.State
|
state *states.State
|
||||||
targets []addrs.Targetable
|
refreshState *states.State
|
||||||
variables InputValues
|
targets []addrs.Targetable
|
||||||
meta *ContextMeta
|
variables InputValues
|
||||||
destroy bool
|
meta *ContextMeta
|
||||||
|
destroy bool
|
||||||
|
|
||||||
hooks []Hook
|
hooks []Hook
|
||||||
components contextComponentFactory
|
components contextComponentFactory
|
||||||
|
@ -223,17 +224,18 @@ func NewContext(opts *ContextOpts) (*Context, tfdiags.Diagnostics) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Context{
|
return &Context{
|
||||||
components: components,
|
components: components,
|
||||||
schemas: schemas,
|
schemas: schemas,
|
||||||
destroy: opts.Destroy,
|
destroy: opts.Destroy,
|
||||||
changes: changes,
|
changes: changes,
|
||||||
hooks: hooks,
|
hooks: hooks,
|
||||||
meta: opts.Meta,
|
meta: opts.Meta,
|
||||||
config: config,
|
config: config,
|
||||||
state: state,
|
state: state,
|
||||||
targets: opts.Targets,
|
refreshState: state.DeepCopy(),
|
||||||
uiInput: opts.UIInput,
|
targets: opts.Targets,
|
||||||
variables: variables,
|
uiInput: opts.UIInput,
|
||||||
|
variables: variables,
|
||||||
|
|
||||||
parallelSem: NewSemaphore(par),
|
parallelSem: NewSemaphore(par),
|
||||||
providerInputConfig: make(map[string]map[string]cty.Value),
|
providerInputConfig: make(map[string]map[string]cty.Value),
|
||||||
|
@ -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