diff --git a/changelog/pending/20240426--cli-display--fix-output-of-the-diff-display-making-sure-it-shows-diffs-from-refreshes.yaml b/changelog/pending/20240426--cli-display--fix-output-of-the-diff-display-making-sure-it-shows-diffs-from-refreshes.yaml new file mode 100644 index 000000000000..44b64a4184d1 --- /dev/null +++ b/changelog/pending/20240426--cli-display--fix-output-of-the-diff-display-making-sure-it-shows-diffs-from-refreshes.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: cli/display + description: Fix output of the diff display, making sure it shows diffs from refreshes diff --git a/pkg/backend/display/display.go b/pkg/backend/display/display.go index be99af23de81..ef4125852ce7 100644 --- a/pkg/backend/display/display.go +++ b/pkg/backend/display/display.go @@ -199,10 +199,12 @@ func shouldShow(step engine.StepEventMetadata, opts Options) bool { return opts.ShowSameResources } - // For logical replacement operations, only show them during progress-style updates (since this is integrated + // For non-logical replacement operations, only show them during progress-style updates (since this is integrated // into the resource status update), or if it is requested explicitly (for diffs and JSON outputs). - if (opts.Type == DisplayDiff || opts.JSONDisplay) && !step.Logical && !opts.ShowReplacementSteps { - return false + if !opts.ShowReplacementSteps { + if (opts.Type == DisplayDiff || opts.JSONDisplay) && !step.Logical && deploy.IsReplacementStep(step.Op) { + return false + } } // Otherwise, default to showing the operation. diff --git a/pkg/resource/deploy/step.go b/pkg/resource/deploy/step.go index bd0872d4271a..ec76492577ec 100644 --- a/pkg/resource/deploy/step.go +++ b/pkg/resource/deploy/step.go @@ -1300,6 +1300,15 @@ var StepOps = []display.StepOp{ OpImportReplacement, } +func IsReplacementStep(op display.StepOp) bool { + if op == OpReplace || op == OpCreateReplacement || op == OpDeleteReplaced || + op == OpReadReplacement || op == OpDiscardReplaced || op == OpRemovePendingReplace || + op == OpImportReplacement { + return true + } + return false +} + // Color returns a suggested color for lines of this op type. func Color(op display.StepOp) string { switch op {