|
|
|
|
@ -5,13 +5,10 @@ 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.
|
|
|
|
|
// PostStateUpdate requires that the state be locked and safe to read for
|
|
|
|
|
// the duration of the call.
|
|
|
|
|
stateSync := ctx.State()
|
|
|
|
|
state := stateSync.Lock().DeepCopy()
|
|
|
|
|
state := stateSync.Lock()
|
|
|
|
|
defer stateSync.Unlock()
|
|
|
|
|
|
|
|
|
|
// Call the hook
|
|
|
|
|
|