func (h *CountHook) PostDiff(
	n *terraform.InstanceInfo, d *terraform.InstanceDiff) (
	terraform.HookAction, error) {
	h.Lock()
	defer h.Unlock()

	switch d.ChangeType() {
	case terraform.DiffDestroyCreate:
		h.ToRemoveAndAdd += 1
	case terraform.DiffCreate:
		h.ToAdd += 1
	case terraform.DiffDestroy:
		h.ToRemove += 1
	case terraform.DiffUpdate:
		h.ToChange += 1
	}

	return terraform.HookActionContinue, nil
}
Beispiel #2
0
// PostDiff is triggered after each individual resource is diffed, and adds
// the required action for each resource to the PlanResponse
func (h *PlanHook) PostDiff(
	n *terraform.InstanceInfo,
	d *terraform.InstanceDiff) (terraform.HookAction, error) {
	h.Lock()
	defer h.Unlock()

	switch d.ChangeType() {
	case terraform.DiffCreate:
		h.resp.Actions[n.HumanId()] = pb.ResourceAction_ActionCreate
	case terraform.DiffUpdate:
		h.resp.Actions[n.HumanId()] = pb.ResourceAction_ActionUpdate
	case terraform.DiffDestroy:
		h.resp.Actions[n.HumanId()] = pb.ResourceAction_ActionDestroy
	case terraform.DiffDestroyCreate:
		h.resp.Actions[n.HumanId()] = pb.ResourceAction_ActionRecreate
	default:
		h.resp.Actions[n.HumanId()] = pb.ResourceAction_ActionNone
	}

	return terraform.HookActionContinue, nil
}