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.
|
// the global state.
|
||||||
State() *states.SyncState
|
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
|
// InstanceExpander returns a helper object for tracking the expansion of
|
||||||
// graph nodes during the plan phase in response to "count" and "for_each"
|
// graph nodes during the plan phase in response to "count" and "for_each"
|
||||||
// arguments.
|
// arguments.
|
||||||
|
@ -71,6 +71,7 @@ type BuiltinEvalContext struct {
|
|||||||
ProvisionerLock *sync.Mutex
|
ProvisionerLock *sync.Mutex
|
||||||
ChangesValue *plans.ChangesSync
|
ChangesValue *plans.ChangesSync
|
||||||
StateValue *states.SyncState
|
StateValue *states.SyncState
|
||||||
|
RefreshStateValue *states.SyncState
|
||||||
InstanceExpanderValue *instances.Expander
|
InstanceExpanderValue *instances.Expander
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,6 +351,10 @@ func (ctx *BuiltinEvalContext) State() *states.SyncState {
|
|||||||
return ctx.StateValue
|
return ctx.StateValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *BuiltinEvalContext) RefreshState() *states.SyncState {
|
||||||
|
return ctx.RefreshStateValue
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *BuiltinEvalContext) InstanceExpander() *instances.Expander {
|
func (ctx *BuiltinEvalContext) InstanceExpander() *instances.Expander {
|
||||||
return ctx.InstanceExpanderValue
|
return ctx.InstanceExpanderValue
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,9 @@ type MockEvalContext struct {
|
|||||||
StateCalled bool
|
StateCalled bool
|
||||||
StateState *states.SyncState
|
StateState *states.SyncState
|
||||||
|
|
||||||
|
RefreshStateCalled bool
|
||||||
|
RefreshStateState *states.SyncState
|
||||||
|
|
||||||
InstanceExpanderCalled bool
|
InstanceExpanderCalled bool
|
||||||
InstanceExpanderExpander *instances.Expander
|
InstanceExpanderExpander *instances.Expander
|
||||||
}
|
}
|
||||||
@ -338,6 +341,11 @@ func (c *MockEvalContext) State() *states.SyncState {
|
|||||||
return c.StateState
|
return c.StateState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *MockEvalContext) RefreshState() *states.SyncState {
|
||||||
|
c.RefreshStateCalled = true
|
||||||
|
return c.RefreshStateState
|
||||||
|
}
|
||||||
|
|
||||||
func (c *MockEvalContext) InstanceExpander() *instances.Expander {
|
func (c *MockEvalContext) InstanceExpander() *instances.Expander {
|
||||||
c.InstanceExpanderCalled = true
|
c.InstanceExpanderCalled = true
|
||||||
return c.InstanceExpanderExpander
|
return c.InstanceExpanderExpander
|
||||||
|
Loading…
Reference in New Issue
Block a user