From 3c9fad0b0e213fae71cd5daf14c6543bf5d424d9 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Thu, 24 Sep 2020 13:49:34 -0400 Subject: [PATCH] Move plan action check into the sensitivity warning method --- command/format/diff.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/command/format/diff.go b/command/format/diff.go index 53e7fd68e3..5baf7d6f89 100644 --- a/command/format/diff.go +++ b/command/format/diff.go @@ -338,10 +338,7 @@ func (p *blockBodyDiffPrinter) writeAttrDiff(name string, attrS *configschema.At p.buf.WriteString("\n") - // Write sensitivity warning for non-delete plans - if action != plans.Delete && action != plans.Create { - p.writeSensitivityWarning(old, new, indent) - } + p.writeSensitivityWarning(old, new, indent, action) p.buf.WriteString(strings.Repeat(" ", indent)) p.writeActionSymbol(action) @@ -1138,7 +1135,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa oldV := old.Index(kV) newV := new.Index(kV) - p.writeSensitivityWarning(oldV, newV, indent+2) + p.writeSensitivityWarning(oldV, newV, indent+2, action) p.buf.WriteString(strings.Repeat(" ", indent+2)) p.writeActionSymbol(action) @@ -1316,7 +1313,12 @@ func (p *blockBodyDiffPrinter) writeActionSymbol(action plans.Action) { } } -func (p *blockBodyDiffPrinter) writeSensitivityWarning(old, new cty.Value, indent int) { +func (p *blockBodyDiffPrinter) writeSensitivityWarning(old, new cty.Value, indent int, action plans.Action) { + // Dont' show this warning for create or delete + if action == plans.Create || action == plans.Delete { + return + } + if new.IsMarked() && !old.IsMarked() { p.buf.WriteString(strings.Repeat(" ", indent)) p.buf.WriteString(p.color.Color("[yellow]# Warning: this attribute value will be marked as sensitive and will\n"))