If the whole map is marked, have the same sensitivity behavior as a single value

This commit is contained in:
Pam Selle 2020-10-01 14:30:33 -04:00
parent 0520f143a2
commit 1780351636
2 changed files with 8 additions and 21 deletions

View File

@ -1070,24 +1070,17 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
return return
case ty.IsMapType(): case ty.IsMapType():
if old.IsMarked() || new.IsMarked() {
p.buf.WriteString("(sensitive)")
return
}
p.buf.WriteString("{") p.buf.WriteString("{")
if p.pathForcesNewResource(path) { if p.pathForcesNewResource(path) {
p.buf.WriteString(p.color.Color(forcesNewResourceCaption)) p.buf.WriteString(p.color.Color(forcesNewResourceCaption))
} }
p.buf.WriteString("\n") p.buf.WriteString("\n")
// If the whole map is marked, we need to show our
// sensitive block warning rather than attempt to iterate
// through a marked map
if old.IsMarked() || new.IsMarked() {
p.buf.WriteString(strings.Repeat(" ", indent+2))
p.buf.WriteString("# This map is (or was) sensitive and will not be displayed")
p.buf.WriteString("\n")
p.buf.WriteString(strings.Repeat(" ", indent))
p.buf.WriteString("}")
return
}
var allKeys []string var allKeys []string
keyLen := 0 keyLen := 0
for it := old.ElementIterator(); it.Next(); { for it := old.ElementIterator(); it.Next(); {

View File

@ -3791,9 +3791,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
} }
# Warning: this attribute value will no longer be marked as sensitive # Warning: this attribute value will no longer be marked as sensitive
# after applying this change # after applying this change
~ map_whole = { ~ map_whole = (sensitive)
# This map is (or was) sensitive and will not be displayed
}
# Warning: this attribute value will no longer be marked as sensitive # Warning: this attribute value will no longer be marked as sensitive
# after applying this change # after applying this change
~ some_number = (sensitive) ~ some_number = (sensitive)
@ -3880,9 +3878,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
} }
# Warning: this attribute value will be marked as sensitive and will # Warning: this attribute value will be marked as sensitive and will
# not display in UI output after applying this change # not display in UI output after applying this change
~ map_whole = { ~ map_whole = (sensitive)
# This map is (or was) sensitive and will not be displayed
}
} }
`, `,
}, },
@ -3981,9 +3977,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
~ "dinner" = (sensitive) ~ "dinner" = (sensitive)
# (1 unchanged element hidden) # (1 unchanged element hidden)
} }
~ map_whole = { ~ map_whole = (sensitive)
# This map is (or was) sensitive and will not be displayed
}
} }
`, `,
}, },