From 896d277a69c2f7f9b52396c65bb5fbf1483ab4da Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Mon, 31 Aug 2020 17:08:10 -0400 Subject: [PATCH] If the path is empty, we should not be marking the path --- command/format/diff.go | 18 ++++++++++-------- terraform/eval_diff.go | 14 ++++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/command/format/diff.go b/command/format/diff.go index 7fa94fadaf..168d170226 100644 --- a/command/format/diff.go +++ b/command/format/diff.go @@ -127,14 +127,16 @@ func ResourceChange( // Now that the change is decoded, add back the marks at the defined paths // change.Markinfo - changeV.Change.After, _ = cty.Transform(changeV.Change.After, func(p cty.Path, v cty.Value) (cty.Value, error) { - if p.Equals(change.ValMarks.Path) { - // TODO The mark is at change.Markinfo.Marks and it would be proper - // to iterate through that set here - return v.Mark("sensitive"), nil - } - return v, nil - }) + if len(change.ValMarks.Path) != 0 { + changeV.Change.After, _ = cty.Transform(changeV.Change.After, func(p cty.Path, v cty.Value) (cty.Value, error) { + if p.Equals(change.ValMarks.Path) { + // TODO The mark is at change.Markinfo.Marks and it would be proper + // to iterate through that set here + return v.Mark("sensitive"), nil + } + return v, nil + }) + } bodyWritten := p.writeBlockBodyDiff(schema, changeV.Before, changeV.After, 6, path) if bodyWritten { diff --git a/terraform/eval_diff.go b/terraform/eval_diff.go index 73e37539fe..6a8cfb7680 100644 --- a/terraform/eval_diff.go +++ b/terraform/eval_diff.go @@ -256,12 +256,14 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) { plannedNewVal := resp.PlannedState // Add the mark back to the planned new value - plannedNewVal, _ = cty.Transform(plannedNewVal, func(p cty.Path, v cty.Value) (cty.Value, error) { - if p.Equals(markedPath) { - return v.Mark("sensitive"), nil - } - return v, nil - }) + if len(markedPath) != 0 { + plannedNewVal, _ = cty.Transform(plannedNewVal, func(p cty.Path, v cty.Value) (cty.Value, error) { + if p.Equals(markedPath) { + return v.Mark("sensitive"), nil + } + return v, nil + }) + } plannedPrivate := resp.PlannedPrivate