mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
add a simple first rendering of action invocations to be run
This commit is contained in:
parent
f72944530d
commit
7d8b79a596
1 changed files with 20 additions and 2 deletions
|
|
@ -85,11 +85,12 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
|
|||
}
|
||||
}
|
||||
|
||||
// Precompute the outputs early, so we can make a decision about whether we
|
||||
// Precompute the outputs and actions early, so we can make a decision about whether we
|
||||
// display the "there are no changes messages".
|
||||
outputs := renderHumanDiffOutputs(renderer, diffs.outputs)
|
||||
actions := renderHumanActionInvocations(renderer, plan.ActionInvocations)
|
||||
|
||||
if len(changes) == 0 && len(outputs) == 0 {
|
||||
if len(changes) == 0 && len(outputs) == 0 && len(actions) == 0 {
|
||||
// If we didn't find any changes to report at all then this is a
|
||||
// "No changes" plan. How we'll present this depends on whether
|
||||
// the plan is "applyable" and, if so, whether it had refresh changes
|
||||
|
|
@ -248,6 +249,11 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q
|
|||
}
|
||||
}
|
||||
|
||||
if len(actions) > 0 {
|
||||
renderer.Streams.Print("\nActions to be invoked:\n")
|
||||
renderer.Streams.Printf("%s\n", actions)
|
||||
}
|
||||
|
||||
if len(outputs) > 0 {
|
||||
renderer.Streams.Print("\nChanges to Outputs:\n")
|
||||
renderer.Streams.Printf("%s\n", outputs)
|
||||
|
|
@ -432,6 +438,18 @@ func renderHumanDeferredDiff(renderer Renderer, deferred deferredDiff) (string,
|
|||
return buf.String(), true
|
||||
}
|
||||
|
||||
func renderHumanActionInvocations(renderer Renderer, actionInvocations []jsonplan.ActionInvocation) string {
|
||||
var buf bytes.Buffer
|
||||
for _, action := range actionInvocations {
|
||||
buf.WriteString(renderer.Colorize.Color(fmt.Sprintf(
|
||||
"[bold] # Triggered by %s[reset]\n",
|
||||
action.TriggeringResourceAddress,
|
||||
)))
|
||||
buf.WriteString(fmt.Sprintf(" %s\n", action.Address))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func resourceChangeComment(resource jsonplan.ResourceChange, action plans.Action, changeCause string) string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue