If the path is empty, we should not be marking the path

This commit is contained in:
Pam Selle 2020-08-31 17:08:10 -04:00
parent 84d118e18f
commit 896d277a69
2 changed files with 18 additions and 14 deletions

View File

@ -127,14 +127,16 @@ func ResourceChange(
// Now that the change is decoded, add back the marks at the defined paths // Now that the change is decoded, add back the marks at the defined paths
// change.Markinfo // change.Markinfo
changeV.Change.After, _ = cty.Transform(changeV.Change.After, func(p cty.Path, v cty.Value) (cty.Value, error) { if len(change.ValMarks.Path) != 0 {
if p.Equals(change.ValMarks.Path) { changeV.Change.After, _ = cty.Transform(changeV.Change.After, func(p cty.Path, v cty.Value) (cty.Value, error) {
// TODO The mark is at change.Markinfo.Marks and it would be proper if p.Equals(change.ValMarks.Path) {
// to iterate through that set here // TODO The mark is at change.Markinfo.Marks and it would be proper
return v.Mark("sensitive"), nil // to iterate through that set here
} return v.Mark("sensitive"), nil
return v, nil }
}) return v, nil
})
}
bodyWritten := p.writeBlockBodyDiff(schema, changeV.Before, changeV.After, 6, path) bodyWritten := p.writeBlockBodyDiff(schema, changeV.Before, changeV.After, 6, path)
if bodyWritten { if bodyWritten {

View File

@ -256,12 +256,14 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
plannedNewVal := resp.PlannedState plannedNewVal := resp.PlannedState
// Add the mark back to the planned new value // Add the mark back to the planned new value
plannedNewVal, _ = cty.Transform(plannedNewVal, func(p cty.Path, v cty.Value) (cty.Value, error) { if len(markedPath) != 0 {
if p.Equals(markedPath) { plannedNewVal, _ = cty.Transform(plannedNewVal, func(p cty.Path, v cty.Value) (cty.Value, error) {
return v.Mark("sensitive"), nil if p.Equals(markedPath) {
} return v.Mark("sensitive"), nil
return v, nil }
}) return v, nil
})
}
plannedPrivate := resp.PlannedPrivate plannedPrivate := resp.PlannedPrivate