Sensitive diffs for primitive types
When showing primitive type diffs, hide possibly sensitive values
This commit is contained in:
parent
20921dbfb8
commit
531728f6e9
|
@ -790,6 +790,11 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
|||
unmarkedNew, _ = new.UnmarkDeep()
|
||||
}
|
||||
switch {
|
||||
case ty == cty.Bool || ty == cty.Number:
|
||||
if old.ContainsMarked() || new.ContainsMarked() {
|
||||
p.buf.WriteString("(sensitive)")
|
||||
return
|
||||
}
|
||||
case ty == cty.String:
|
||||
// We have special behavior for both multi-line strings in general
|
||||
// and for strings that can parse as JSON. For the JSON handling
|
||||
|
|
|
@ -3652,36 +3652,57 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
|
|||
}
|
||||
`,
|
||||
},
|
||||
"in-place update - before sensitive": {
|
||||
"in-place update - before sensitive, primitive types": {
|
||||
Action: plans.Update,
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Before: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-BEFORE"),
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-BEFORE"),
|
||||
"special": cty.BoolVal(true),
|
||||
"some_number": cty.NumberIntVal(1),
|
||||
}),
|
||||
After: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-AFTER"),
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-AFTER"),
|
||||
"special": cty.BoolVal(false),
|
||||
"some_number": cty.NumberIntVal(2),
|
||||
}),
|
||||
BeforeValMarks: []cty.PathValueMarks{
|
||||
{
|
||||
Path: cty.Path{cty.GetAttrStep{Name: "ami"}},
|
||||
Marks: cty.NewValueMarks("sensitive"),
|
||||
}},
|
||||
},
|
||||
{
|
||||
Path: cty.Path{cty.GetAttrStep{Name: "special"}},
|
||||
Marks: cty.NewValueMarks("sensitive"),
|
||||
},
|
||||
{
|
||||
Path: cty.Path{cty.GetAttrStep{Name: "some_number"}},
|
||||
Marks: cty.NewValueMarks("sensitive"),
|
||||
},
|
||||
},
|
||||
RequiredReplace: cty.NewPathSet(),
|
||||
Tainted: false,
|
||||
Schema: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
"id": {Type: cty.String, Optional: true, Computed: true},
|
||||
"ami": {Type: cty.String, Optional: true},
|
||||
"id": {Type: cty.String, Optional: true, Computed: true},
|
||||
"ami": {Type: cty.String, Optional: true},
|
||||
"special": {Type: cty.Bool, Optional: true},
|
||||
"some_number": {Type: cty.Number, Optional: true},
|
||||
},
|
||||
},
|
||||
ExpectedOutput: ` # test_instance.example will be updated in-place
|
||||
~ resource "test_instance" "example" {
|
||||
# Warning: this attribute value will no longer be marked as sensitive
|
||||
# after applying this change
|
||||
~ ami = (sensitive)
|
||||
id = "i-02ae66f368e8518a9"
|
||||
~ ami = (sensitive)
|
||||
id = "i-02ae66f368e8518a9"
|
||||
# Warning: this attribute value will no longer be marked as sensitive
|
||||
# after applying this change
|
||||
~ some_number = (sensitive)
|
||||
# Warning: this attribute value will no longer be marked as sensitive
|
||||
# after applying this change
|
||||
~ special = (sensitive)
|
||||
}
|
||||
`,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue