command: Show id only when refreshing managed resources

Data resources don't have ids when they refresh, so we'll skip showing the
"(ID: ...)"  indicator for these. Showing it with no id makes it look
like something is broken.
This commit is contained in:
Martin Atkins 2016-05-07 23:51:55 -07:00
parent 60c24e3319
commit 5d27a5b3e2
1 changed files with 10 additions and 2 deletions

View File

@ -245,9 +245,17 @@ func (h *UiHook) PreRefresh(
h.once.Do(h.init) h.once.Do(h.init)
id := n.HumanId() id := n.HumanId()
var stateIdSuffix string
// Data resources refresh before they have ids, whereas managed
// resources are only refreshed when they have ids.
if s.ID != "" {
stateIdSuffix = fmt.Sprintf(" (ID: %s)", s.ID)
}
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...%s",
id, s.ID))) id, stateIdSuffix)))
return terraform.HookActionContinue, nil return terraform.HookActionContinue, nil
} }