From ea20db63fbc69544a4504e190d566e44b201680a Mon Sep 17 00:00:00 2001 From: Akella Umesh Date: Thu, 2 Oct 2025 16:00:05 +0200 Subject: [PATCH] actions: add missing actions output for terraform apply cli (#37692) --- .changes/v1.14/BUGFIX-20250927-184134.yaml | 5 +++++ internal/command/views/apply.go | 23 +++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .changes/v1.14/BUGFIX-20250927-184134.yaml diff --git a/.changes/v1.14/BUGFIX-20250927-184134.yaml b/.changes/v1.14/BUGFIX-20250927-184134.yaml new file mode 100644 index 0000000000..a6772d3afb --- /dev/null +++ b/.changes/v1.14/BUGFIX-20250927-184134.yaml @@ -0,0 +1,5 @@ +kind: BUGFIX +body: The CLI now summarizes the number of actions invoked during `terraform apply`, matching the plan output. +time: 2025-09-27T18:41:34.771437+02:00 +custom: + Issue: "37689" diff --git a/internal/command/views/apply.go b/internal/command/views/apply.go index 5c623bf625..b998643775 100644 --- a/internal/command/views/apply.go +++ b/internal/command/views/apply.go @@ -61,27 +61,26 @@ type ApplyHuman struct { var _ Apply = (*ApplyHuman)(nil) func (v *ApplyHuman) ResourceCount(stateOutPath string) { + var summary string if v.destroy { - v.view.streams.Printf( - v.view.colorize.Color("[reset][bold][green]\nDestroy complete! Resources: %d destroyed.\n"), - v.countHook.Removed, - ) + summary = fmt.Sprintf("Destroy complete! Resources: %d destroyed.", v.countHook.Removed) } else if v.countHook.Imported > 0 { - v.view.streams.Printf( - v.view.colorize.Color("[reset][bold][green]\nApply complete! Resources: %d imported, %d added, %d changed, %d destroyed.\n"), + summary = fmt.Sprintf("Apply complete! Resources: %d imported, %d added, %d changed, %d destroyed.", v.countHook.Imported, v.countHook.Added, v.countHook.Changed, - v.countHook.Removed, - ) + v.countHook.Removed) } else { - v.view.streams.Printf( - v.view.colorize.Color("[reset][bold][green]\nApply complete! Resources: %d added, %d changed, %d destroyed.\n"), + summary = fmt.Sprintf("Apply complete! Resources: %d added, %d changed, %d destroyed.", v.countHook.Added, v.countHook.Changed, - v.countHook.Removed, - ) + v.countHook.Removed) } + v.view.streams.Print(v.view.colorize.Color("[reset][bold][green]\n" + summary)) + if v.countHook.ActionInvocation > 0 { + v.view.streams.Print(v.view.colorize.Color(fmt.Sprintf("[reset][bold][green] Actions: %d invoked.", v.countHook.ActionInvocation))) + } + v.view.streams.Print("\n") if (v.countHook.Added > 0 || v.countHook.Changed > 0) && stateOutPath != "" { v.view.streams.Printf("\n%s\n\n", format.WordWrap(stateOutPathPostApply, v.view.outputColumns())) v.view.streams.Printf("State path: %s\n", stateOutPath)