check for IsComputed when validating a schema obj
GH-14784 allowed nested structures to be validate, rather than relying on the raw value. However this still returns the same validation error if the structures contain a computed value, since Get will return the raw string in that case. This simply skips the validation in the IsComputed case, since there's nothing that can be checked.
This commit is contained in:
parent
d34dee5cc4
commit
6bc52be0a5
|
@ -1374,7 +1374,7 @@ func (m schemaMap) validateObject(
|
|||
schema map[string]*Schema,
|
||||
c *terraform.ResourceConfig) ([]string, []error) {
|
||||
raw, _ := c.Get(k)
|
||||
if _, ok := raw.(map[string]interface{}); !ok {
|
||||
if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) {
|
||||
return nil, []error{fmt.Errorf(
|
||||
"%s: expected object, got %s",
|
||||
k, reflect.ValueOf(raw).Kind())}
|
||||
|
|
|
@ -3974,6 +3974,35 @@ func TestSchemaMap_Validate(t *testing.T) {
|
|||
Err: false,
|
||||
},
|
||||
|
||||
"Good sub-resource, computed value": {
|
||||
Schema: map[string]*Schema{
|
||||
"ingress": &Schema{
|
||||
Type: TypeList,
|
||||
Optional: true,
|
||||
Elem: &Resource{
|
||||
Schema: map[string]*Schema{
|
||||
"from": &Schema{
|
||||
Type: TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Config: map[string]interface{}{
|
||||
"ingress": []interface{}{
|
||||
`${map("from", var.port)}`,
|
||||
},
|
||||
},
|
||||
|
||||
Vars: map[string]string{
|
||||
"var.port": config.UnknownVariableValue,
|
||||
},
|
||||
|
||||
Err: false,
|
||||
},
|
||||
|
||||
"Invalid/unknown field": {
|
||||
Schema: map[string]*Schema{
|
||||
"availability_zone": &Schema{
|
||||
|
|
Loading…
Reference in New Issue