diff --git a/command/hook_count.go b/command/hook_count.go index 08dd98fd7..21e1ea160 100644 --- a/command/hook_count.go +++ b/command/hook_count.go @@ -38,7 +38,7 @@ func (h *CountHook) Reset() { } func (h *CountHook) PreApply( - id string, + n *terraform.InstanceInfo, s *terraform.InstanceState, d *terraform.InstanceDiff) (terraform.HookAction, error) { h.Lock() @@ -55,21 +55,21 @@ func (h *CountHook) PreApply( action = countHookActionAdd } - h.pending[id] = action + h.pending[n.HumanId()] = action return terraform.HookActionContinue, nil } func (h *CountHook) PostApply( - id string, + n *terraform.InstanceInfo, s *terraform.InstanceState, e error) (terraform.HookAction, error) { h.Lock() defer h.Unlock() if h.pending != nil { - if a, ok := h.pending[id]; ok { - delete(h.pending, id) + if a, ok := h.pending[n.HumanId()]; ok { + delete(h.pending, n.HumanId()) if e == nil { switch a { diff --git a/command/hook_ui.go b/command/hook_ui.go index 16c1d7507..b86701f5e 100644 --- a/command/hook_ui.go +++ b/command/hook_ui.go @@ -34,11 +34,13 @@ const ( ) func (h *UiHook) PreApply( - id string, + n *terraform.InstanceInfo, s *terraform.InstanceState, d *terraform.InstanceDiff) (terraform.HookAction, error) { h.once.Do(h.init) + id := n.HumanId() + op := uiResourceModify if d.Destroy { op = uiResourceDestroy @@ -113,9 +115,11 @@ func (h *UiHook) PreApply( } func (h *UiHook) PostApply( - id string, + n *terraform.InstanceInfo, s *terraform.InstanceState, applyerr error) (terraform.HookAction, error) { + id := n.HumanId() + h.l.Lock() op := h.resources[id] delete(h.resources, id) @@ -145,11 +149,15 @@ func (h *UiHook) PostApply( } func (h *UiHook) PreDiff( - id string, s *terraform.InstanceState) (terraform.HookAction, error) { + n *terraform.InstanceInfo, + s *terraform.InstanceState) (terraform.HookAction, error) { return terraform.HookActionContinue, nil } -func (h *UiHook) PreProvision(id, provId string) (terraform.HookAction, error) { +func (h *UiHook) PreProvision( + n *terraform.InstanceInfo, + provId string) (terraform.HookAction, error) { + id := n.HumanId() h.ui.Output(h.Colorize.Color(fmt.Sprintf( "[reset][bold]%s: Provisioning with '%s'...[reset_bold]", id, provId))) @@ -157,9 +165,11 @@ func (h *UiHook) PreProvision(id, provId string) (terraform.HookAction, error) { } func (h *UiHook) PreRefresh( - id string, s *terraform.InstanceState) (terraform.HookAction, error) { + n *terraform.InstanceInfo, + s *terraform.InstanceState) (terraform.HookAction, error) { h.once.Do(h.init) + id := n.HumanId() h.ui.Output(h.Colorize.Color(fmt.Sprintf( "[reset][bold]%s: Refreshing state... (ID: %s)", id, s.ID)))