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
// 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 {

View File

@ -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