mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Add RefreshState to the eval context
Since plan uses the state as a scratch space for evaluation, we need an entirely separate state to store the refreshed resources values during planning. Add a RefreshState method to the EvalContext to retrieve a state used only for refreshing resources.
This commit is contained in:
parent
be757bd416
commit
d6a586709c
@ -152,6 +152,11 @@ type EvalContext interface {
|
||||
// the global state.
|
||||
State() *states.SyncState
|
||||
|
||||
// RefreshState returns a wrapper object that provides safe concurrent
|
||||
// access to the state used to store the most recently refreshed resource
|
||||
// values.
|
||||
RefreshState() *states.SyncState
|
||||
|
||||
// InstanceExpander returns a helper object for tracking the expansion of
|
||||
// graph nodes during the plan phase in response to "count" and "for_each"
|
||||
// arguments.
|
||||
|
@ -71,6 +71,7 @@ type BuiltinEvalContext struct {
|
||||
ProvisionerLock *sync.Mutex
|
||||
ChangesValue *plans.ChangesSync
|
||||
StateValue *states.SyncState
|
||||
RefreshStateValue *states.SyncState
|
||||
InstanceExpanderValue *instances.Expander
|
||||
}
|
||||
|
||||
@ -350,6 +351,10 @@ func (ctx *BuiltinEvalContext) State() *states.SyncState {
|
||||
return ctx.StateValue
|
||||
}
|
||||
|
||||
func (ctx *BuiltinEvalContext) RefreshState() *states.SyncState {
|
||||
return ctx.RefreshStateValue
|
||||
}
|
||||
|
||||
func (ctx *BuiltinEvalContext) InstanceExpander() *instances.Expander {
|
||||
return ctx.InstanceExpanderValue
|
||||
}
|
||||
|
@ -126,6 +126,9 @@ type MockEvalContext struct {
|
||||
StateCalled bool
|
||||
StateState *states.SyncState
|
||||
|
||||
RefreshStateCalled bool
|
||||
RefreshStateState *states.SyncState
|
||||
|
||||
InstanceExpanderCalled bool
|
||||
InstanceExpanderExpander *instances.Expander
|
||||
}
|
||||
@ -338,6 +341,11 @@ func (c *MockEvalContext) State() *states.SyncState {
|
||||
return c.StateState
|
||||
}
|
||||
|
||||
func (c *MockEvalContext) RefreshState() *states.SyncState {
|
||||
c.RefreshStateCalled = true
|
||||
return c.RefreshStateState
|
||||
}
|
||||
|
||||
func (c *MockEvalContext) InstanceExpander() *instances.Expander {
|
||||
c.InstanceExpanderCalled = true
|
||||
return c.InstanceExpanderExpander
|
||||
|
Loading…
Reference in New Issue
Block a user