mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-29 10:21:01 -06:00
36d0a50427
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
20 lines
663 B
Go
20 lines
663 B
Go
package terraform
|
|
|
|
// updateStateHook calls the PostStateUpdate hook with the current state.
|
|
func updateStateHook(ctx EvalContext) error {
|
|
// In principle we could grab the lock here just long enough to take a
|
|
// deep copy and then pass that to our hooks below, but we'll instead
|
|
// hold the hook for the duration to avoid the potential confusing
|
|
// situation of us racing to call PostStateUpdate concurrently with
|
|
// different state snapshots.
|
|
stateSync := ctx.State()
|
|
state := stateSync.Lock().DeepCopy()
|
|
defer stateSync.Unlock()
|
|
|
|
// Call the hook
|
|
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
|
return h.PostStateUpdate(state)
|
|
})
|
|
return err
|
|
}
|