helper/schema: validate unknown fields with computed values [GH-1507]

This commit is contained in:
Mitchell Hashimoto 2015-04-22 12:52:26 +02:00
parent a27890b1a6
commit 1f46bc1926
2 changed files with 22 additions and 1 deletions

View File

@ -1078,7 +1078,7 @@ func (m schemaMap) validateObject(
}
// Detect any extra/unknown keys and report those as errors.
raw, _ := c.Get(k)
raw, _ := c.GetRaw(k)
if m, ok := raw.(map[string]interface{}); ok {
for subk, _ := range m {
if _, ok := schema[subk]; !ok {

View File

@ -2933,6 +2933,27 @@ func TestSchemaMap_Validate(t *testing.T) {
Err: true,
},
"Invalid/unknown field with computed value": {
Schema: map[string]*Schema{
"availability_zone": &Schema{
Type: TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
Config: map[string]interface{}{
"foo": "${var.foo}",
},
Vars: map[string]string{
"var.foo": config.UnknownVariableValue,
},
Err: true,
},
"Computed field set": {
Schema: map[string]*Schema{
"availability_zone": &Schema{