Update compatibility checks for blocks to not use marks

Remove marks for object compatibility tests to allow apply
to continue. Adds a block to the test provider to use
in testing, and extends the sensitivity apply test to include a block
This commit is contained in:
Pam Selle 2020-09-29 13:48:22 -04:00
parent 73b1d8b0d1
commit f35b530837
3 changed files with 24 additions and 3 deletions

View File

@ -73,8 +73,9 @@ func assertObjectCompatible(schema *configschema.Block, planned, actual cty.Valu
}
}
for name, blockS := range schema.BlockTypes {
plannedV := planned.GetAttr(name)
actualV := actual.GetAttr(name)
// Unmark values before testing compatibility
plannedV, _ := planned.GetAttr(name).UnmarkDeep()
actualV, _ := actual.GetAttr(name).UnmarkDeep()
// As a special case, if there were any blocks whose leaf attributes
// are all unknown then we assume (possibly incorrectly) that the

View File

@ -11939,8 +11939,17 @@ variable "sensitive_var" {
sensitive = true
}
variable "sensitive_id" {
default = "secret id"
sensitive = true
}
resource "test_resource" "foo" {
value = var.sensitive_var
network_interface {
network_interface_id = var.sensitive_id
}
}`,
})
@ -11982,7 +11991,7 @@ resource "test_resource" "foo" {
t.Fatalf("apply errors: %s", diags.Err())
}
// Now change the variable value
// Now change the variable value for sensitive_var
ctx = testContext2(t, &ContextOpts{
Config: m,
Providers: map[addrs.Provider]providers.Factory{

View File

@ -636,6 +636,17 @@ func testProviderSchema(name string) *ProviderSchema {
Optional: true,
},
},
BlockTypes: map[string]*configschema.NestedBlock{
"network_interface": {
Block: configschema.Block{
Attributes: map[string]*configschema.Attribute{
"network_interface_id": {Type: cty.String, Optional: true},
"device_index": {Type: cty.Number, Optional: true},
},
},
Nesting: configschema.NestingSet,
},
},
},
name + "_ami_list": {
Attributes: map[string]*configschema.Attribute{