Skip to content

Commit

Permalink
Never show property diffs for OpSame
Browse files Browse the repository at this point in the history
Fixes #15944.
  • Loading branch information
Frassle committed Apr 22, 2024
1 parent e554b26 commit 455a3dd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
25 changes: 14 additions & 11 deletions pkg/backend/display/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,20 +387,23 @@ func renderDiff(
summary := getResourcePropertiesSummary(metadata, indent)

var details string
if metadata.DetailedDiff != nil {
var buf bytes.Buffer
if diff := engine.TranslateDetailedDiff(&metadata); diff != nil {
PrintObjectDiff(&buf, *diff, nil /*include*/, planning, indent+1, opts.SummaryDiff, opts.TruncateOutput, debug)
// An OpSame might have a diff due to metadata changes (e.g. protect) but we should never print a property diff,
// even if the properties appear to have changed. See https://github.com/pulumi/pulumi/issues/15944 for context.
if metadata.Op != deploy.OpSame {
if metadata.DetailedDiff != nil {
var buf bytes.Buffer
if diff := engine.TranslateDetailedDiff(&metadata); diff != nil {
PrintObjectDiff(&buf, *diff, nil /*include*/, planning, indent+1, opts.SummaryDiff, opts.TruncateOutput, debug)
} else {
PrintObject(
&buf, metadata.Old.Inputs, planning, indent+1, deploy.OpSame, true /*prefix*/, opts.TruncateOutput, debug)
}
details = buf.String()
} else {
PrintObject(
&buf, metadata.Old.Inputs, planning, indent+1, deploy.OpSame, true /*prefix*/, opts.TruncateOutput, debug)
details = getResourcePropertiesDetails(
metadata, indent, planning, opts.SummaryDiff, opts.TruncateOutput, debug)
}
details = buf.String()
} else {
details = getResourcePropertiesDetails(
metadata, indent, planning, opts.SummaryDiff, opts.TruncateOutput, debug)
}

fprintIgnoreError(out, opts.Color.Colorize(summary))
fprintIgnoreError(out, opts.Color.Colorize(details))
fprintIgnoreError(out, opts.Color.Colorize(colors.Reset))
Expand Down
18 changes: 11 additions & 7 deletions pkg/backend/display/rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,18 @@ func getDiffInfo(step engine.StepEventMetadata, action apitype.UpdateKind) strin
changesBuf := &bytes.Buffer{}
if step.Old != nil && step.New != nil {
var diff *resource.ObjectDiff
if step.DetailedDiff != nil {
diff = engine.TranslateDetailedDiff(&step)
} else if diffOutputs {
if step.Old.Outputs != nil && step.New.Outputs != nil {
diff = step.Old.Outputs.Diff(step.New.Outputs)
// An OpSame might have a diff due to metadata changes (e.g. protect) but we should never print a property diff,
// even if the properties appear to have changed. See https://github.com/pulumi/pulumi/issues/15944 for context.
if step.Op != deploy.OpSame {
if step.DetailedDiff != nil {
diff = engine.TranslateDetailedDiff(&step)
} else if diffOutputs {
if step.Old.Outputs != nil && step.New.Outputs != nil {
diff = step.Old.Outputs.Diff(step.New.Outputs)
}
} else if step.Old.Inputs != nil && step.New.Inputs != nil {
diff = step.Old.Inputs.Diff(step.New.Inputs)
}
} else if step.Old.Inputs != nil && step.New.Inputs != nil {
diff = step.Old.Inputs.Diff(step.New.Inputs)
}

// Show a diff if either `provider` or `protect` changed; they might not show a diff via inputs or outputs, but
Expand Down

0 comments on commit 455a3dd

Please sign in to comment.