From 5b549224ae67b629582de47e16ddd2fe19a30f4d Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Thu, 24 Sep 2020 16:42:03 -0400 Subject: [PATCH] Refactor to call ContainsMarked less and use len() instead --- command/format/diff.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/command/format/diff.go b/command/format/diff.go index 5baf7d6f8..815899058 100644 --- a/command/format/diff.go +++ b/command/format/diff.go @@ -777,18 +777,12 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa // However, these specialized implementations can apply only if both // values are known and non-null. if old.IsKnown() && new.IsKnown() && !old.IsNull() && !new.IsNull() && typesEqual { - // If marked, create unmarked values for comparisons - unmarkedOld := old - unmarkedNew := new - if old.ContainsMarked() { - unmarkedOld, _ = old.UnmarkDeep() - } - if new.ContainsMarked() { - unmarkedNew, _ = new.UnmarkDeep() - } + // Create unmarked values for comparisons + unmarkedOld, oldMarks := old.UnmarkDeep() + unmarkedNew, newMarks := new.UnmarkDeep() switch { case ty == cty.Bool || ty == cty.Number: - if old.ContainsMarked() || new.ContainsMarked() { + if len(oldMarks) > 0 || len(newMarks) > 0 { p.buf.WriteString("(sensitive)") return } @@ -799,7 +793,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa // For single-line strings that don't parse as JSON we just fall // out of this switch block and do the default old -> new rendering. - if old.ContainsMarked() || new.ContainsMarked() { + if len(oldMarks) > 0 || len(newMarks) > 0 { p.buf.WriteString("(sensitive)") return }