Merge pull request #12370 from hashicorp/b-hook-ui-fix
command: Fix crash caused by empty state (data source PostApply)
This commit is contained in:
commit
dd8a93ec8d
|
@ -129,8 +129,9 @@ func (h *UiHook) PreApply(
|
||||||
attrString = "\n " + attrString
|
attrString = "\n " + attrString
|
||||||
}
|
}
|
||||||
|
|
||||||
var stateIdSuffix string
|
var stateId, stateIdSuffix string
|
||||||
if s.ID != "" {
|
if s != nil && s.ID != "" {
|
||||||
|
stateId = s.ID
|
||||||
stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen))
|
stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ func (h *UiHook) PreApply(
|
||||||
attrString)))
|
attrString)))
|
||||||
|
|
||||||
// Set a timer to show an operation is still happening
|
// 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
|
return terraform.HookActionContinue, nil
|
||||||
}
|
}
|
||||||
|
@ -200,7 +201,7 @@ func (h *UiHook) PostApply(
|
||||||
h.l.Unlock()
|
h.l.Unlock()
|
||||||
|
|
||||||
var stateIdSuffix string
|
var stateIdSuffix string
|
||||||
if s.ID != "" {
|
if s != nil && s.ID != "" {
|
||||||
stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen))
|
stateIdSuffix = fmt.Sprintf(" (ID: %s)", truncateId(s.ID, maxIdLen))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue