Merge pull request #14784 from mattrobenolt/validateobject

helper/schema: fix validating nested objects
This commit is contained in:
James Bardin 2017-05-24 12:27:40 -04:00 committed by GitHub
commit d34dee5cc4
2 changed files with 28 additions and 1 deletions

View File

@ -1373,7 +1373,7 @@ func (m schemaMap) validateObject(
k string, k string,
schema map[string]*Schema, schema map[string]*Schema,
c *terraform.ResourceConfig) ([]string, []error) { c *terraform.ResourceConfig) ([]string, []error) {
raw, _ := c.GetRaw(k) raw, _ := c.Get(k)
if _, ok := raw.(map[string]interface{}); !ok { if _, ok := raw.(map[string]interface{}); !ok {
return nil, []error{fmt.Errorf( return nil, []error{fmt.Errorf(
"%s: expected object, got %s", "%s: expected object, got %s",

View File

@ -3947,6 +3947,33 @@ func TestSchemaMap_Validate(t *testing.T) {
Err: false, Err: false,
}, },
"Good sub-resource, interpolated value": {
Schema: map[string]*Schema{
"ingress": &Schema{
Type: TypeList,
Optional: true,
Elem: &Resource{
Schema: map[string]*Schema{
"from": &Schema{
Type: TypeInt,
Required: true,
},
},
},
},
},
Config: map[string]interface{}{
"ingress": []interface{}{
`${map("from", "80")}`,
},
},
Vars: map[string]string{},
Err: false,
},
"Invalid/unknown field": { "Invalid/unknown field": {
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"availability_zone": &Schema{ "availability_zone": &Schema{