command: render new modules properly

This commit is contained in:
Mitchell Hashimoto 2014-09-25 14:52:06 -07:00
parent 1835a03842
commit 5f791051a6
2 changed files with 20 additions and 10 deletions

View File

@ -38,7 +38,7 @@ func (h *CountHook) Reset() {
} }
func (h *CountHook) PreApply( func (h *CountHook) PreApply(
id string, n *terraform.InstanceInfo,
s *terraform.InstanceState, s *terraform.InstanceState,
d *terraform.InstanceDiff) (terraform.HookAction, error) { d *terraform.InstanceDiff) (terraform.HookAction, error) {
h.Lock() h.Lock()
@ -55,21 +55,21 @@ func (h *CountHook) PreApply(
action = countHookActionAdd action = countHookActionAdd
} }
h.pending[id] = action h.pending[n.HumanId()] = action
return terraform.HookActionContinue, nil return terraform.HookActionContinue, nil
} }
func (h *CountHook) PostApply( func (h *CountHook) PostApply(
id string, n *terraform.InstanceInfo,
s *terraform.InstanceState, s *terraform.InstanceState,
e error) (terraform.HookAction, error) { e error) (terraform.HookAction, error) {
h.Lock() h.Lock()
defer h.Unlock() defer h.Unlock()
if h.pending != nil { if h.pending != nil {
if a, ok := h.pending[id]; ok { if a, ok := h.pending[n.HumanId()]; ok {
delete(h.pending, id) delete(h.pending, n.HumanId())
if e == nil { if e == nil {
switch a { switch a {

View File

@ -34,11 +34,13 @@ const (
) )
func (h *UiHook) PreApply( func (h *UiHook) PreApply(
id string, n *terraform.InstanceInfo,
s *terraform.InstanceState, s *terraform.InstanceState,
d *terraform.InstanceDiff) (terraform.HookAction, error) { d *terraform.InstanceDiff) (terraform.HookAction, error) {
h.once.Do(h.init) h.once.Do(h.init)
id := n.HumanId()
op := uiResourceModify op := uiResourceModify
if d.Destroy { if d.Destroy {
op = uiResourceDestroy op = uiResourceDestroy
@ -113,9 +115,11 @@ func (h *UiHook) PreApply(
} }
func (h *UiHook) PostApply( func (h *UiHook) PostApply(
id string, n *terraform.InstanceInfo,
s *terraform.InstanceState, s *terraform.InstanceState,
applyerr error) (terraform.HookAction, error) { applyerr error) (terraform.HookAction, error) {
id := n.HumanId()
h.l.Lock() h.l.Lock()
op := h.resources[id] op := h.resources[id]
delete(h.resources, id) delete(h.resources, id)
@ -145,11 +149,15 @@ func (h *UiHook) PostApply(
} }
func (h *UiHook) PreDiff( 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 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( h.ui.Output(h.Colorize.Color(fmt.Sprintf(
"[reset][bold]%s: Provisioning with '%s'...[reset_bold]", "[reset][bold]%s: Provisioning with '%s'...[reset_bold]",
id, provId))) id, provId)))
@ -157,9 +165,11 @@ func (h *UiHook) PreProvision(id, provId string) (terraform.HookAction, error) {
} }
func (h *UiHook) PreRefresh( 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) h.once.Do(h.init)
id := n.HumanId()
h.ui.Output(h.Colorize.Color(fmt.Sprintf( h.ui.Output(h.Colorize.Color(fmt.Sprintf(
"[reset][bold]%s: Refreshing state... (ID: %s)", "[reset][bold]%s: Refreshing state... (ID: %s)",
id, s.ID))) id, s.ID)))