Merge pull request #25013 from hashicorp/alisdair/ui-data-source-read

command: Add UI hooks for read actions
This commit is contained in:
Alisdair McDiarmid 2020-05-26 15:59:30 -04:00 committed by GitHub
commit 5d0b75df7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -60,6 +60,7 @@ const (
uiResourceCreate uiResourceCreate
uiResourceModify uiResourceModify
uiResourceDestroy uiResourceDestroy
uiResourceRead
) )
func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (terraform.HookAction, error) { func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (terraform.HookAction, error) {
@ -83,6 +84,9 @@ func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation,
case plans.Update: case plans.Update:
operation = "Modifying..." operation = "Modifying..."
op = uiResourceModify op = uiResourceModify
case plans.Read:
operation = "Reading..."
op = uiResourceRead
default: default:
// We don't expect any other actions in here, so anything else is a // We don't expect any other actions in here, so anything else is a
// bug in the caller but we'll ignore it in order to be robust. // bug in the caller but we'll ignore it in order to be robust.
@ -196,6 +200,8 @@ func (h *UiHook) stillApplying(state uiResourceState) {
msg = "Still destroying..." msg = "Still destroying..."
case uiResourceCreate: case uiResourceCreate:
msg = "Still creating..." msg = "Still creating..."
case uiResourceRead:
msg = "Still reading..."
case uiResourceUnknown: case uiResourceUnknown:
return return
} }
@ -241,6 +247,8 @@ func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation
msg = "Destruction complete" msg = "Destruction complete"
case uiResourceCreate: case uiResourceCreate:
msg = "Creation complete" msg = "Creation complete"
case uiResourceRead:
msg = "Read complete"
case uiResourceUnknown: case uiResourceUnknown:
return terraform.HookActionContinue, nil return terraform.HookActionContinue, nil
} }