helper/schema: validate Set is a set type [GH-413]

This commit is contained in:
Mitchell Hashimoto 2014-10-17 23:23:50 -07:00
parent 1912e9655d
commit 2b50d44aa4
3 changed files with 23 additions and 0 deletions

View File

@ -9,6 +9,7 @@ BUG FIXES:
computed so the value is still unknown.
* core: If a resource fails to create and has provisioners, it is
marked as tainted. [GH-434]
* core: Set types are validated to be sets. [GH-413]
* providers/aws: Refresh of launch configs and autoscale groups load
the correct data and don't incorrectly recreate themselves. [GH-425]
* providers/aws: Fix case where ELB would incorrectly plan to modify

View File

@ -819,6 +819,8 @@ func (m schemaMap) validatePrimitive(
}
switch schema.Type {
case TypeSet:
fallthrough
case TypeList:
return m.validateList(k, raw, schema, c)
case TypeInt:

View File

@ -1970,6 +1970,26 @@ func TestSchemaMap_Validate(t *testing.T) {
Err: true,
},
// Not a set
{
Schema: map[string]*Schema{
"ports": &Schema{
Type: TypeSet,
Required: true,
Elem: &Schema{Type: TypeInt},
Set: func(a interface{}) int {
return a.(int)
},
},
},
Config: map[string]interface{}{
"ports": "foo",
},
Err: true,
},
}
for i, tc := range cases {