From 08283f077be4029a1575354ea5c5bed7fc6fd86a Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 2 Mar 2017 10:52:16 +0000 Subject: [PATCH] command: Fix crash caused by empty state --- command/hook_ui.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/command/hook_ui.go b/command/hook_ui.go index 0bc1e906f..06f3cce52 100644 --- a/command/hook_ui.go +++ b/command/hook_ui.go @@ -129,8 +129,9 @@ func (h *UiHook) PreApply( attrString = "\n " + attrString } - var stateIdSuffix string - if s.ID != "" { + var stateId, stateIdSuffix string + if s != nil && s.ID != "" { + stateId = s.ID stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen)) } @@ -142,7 +143,7 @@ func (h *UiHook) PreApply( attrString))) // Set a timer to show an operation is still happening - time.AfterFunc(periodicUiTimer, func() { h.stillApplying(id, s.ID) }) + time.AfterFunc(periodicUiTimer, func() { h.stillApplying(id, stateId) }) return terraform.HookActionContinue, nil } @@ -200,7 +201,7 @@ func (h *UiHook) PostApply( h.l.Unlock() var stateIdSuffix string - if s.ID != "" { + if s != nil && s.ID != "" { stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen)) }