6 "github.com/zclconf/go-cty/cty"
8 "github.com/hashicorp/terraform/addrs"
9 "github.com/hashicorp/terraform/plans"
10 "github.com/hashicorp/terraform/providers"
11 "github.com/hashicorp/terraform/states"
14 // stopHook is a private Hook implementation that Terraform uses to
15 // signal when to stop or cancel actions.
16 type stopHook struct {
20 var _ Hook = (*stopHook)(nil)
22 func (h *stopHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error) {
26 func (h *stopHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, err error) (HookAction, error) {
30 func (h *stopHook) PreDiff(addr addrs.AbsResourceInstance, gen states.Generation, priorState, proposedNewState cty.Value) (HookAction, error) {
34 func (h *stopHook) PostDiff(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error) {
38 func (h *stopHook) PreProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error) {
42 func (h *stopHook) PostProvisionInstance(addr addrs.AbsResourceInstance, state cty.Value) (HookAction, error) {
46 func (h *stopHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (HookAction, error) {
50 func (h *stopHook) PostProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string, err error) (HookAction, error) {
54 func (h *stopHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, line string) {
57 func (h *stopHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (HookAction, error) {
61 func (h *stopHook) PostRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value, newState cty.Value) (HookAction, error) {
65 func (h *stopHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (HookAction, error) {
69 func (h *stopHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error) {
73 func (h *stopHook) PostStateUpdate(new *states.State) (HookAction, error) {
77 func (h *stopHook) hook() (HookAction, error) {
79 // FIXME: This should really return an error since stopping partway
80 // through is not a successful run-to-completion, but we'll need to
81 // introduce that cautiously since existing automation solutions may
82 // be depending on this behavior.
83 return HookActionHalt, nil
86 return HookActionContinue, nil
89 // reset should be called within the lock context
90 func (h *stopHook) Reset() {
91 atomic.StoreUint32(&h.stop, 0)
94 func (h *stopHook) Stop() {
95 atomic.StoreUint32(&h.stop, 1)
98 func (h *stopHook) Stopped() bool {
99 return atomic.LoadUint32(&h.stop) == 1