helper/schema: validate unknown fields with computed values [GH-1507]
This commit is contained in:
parent
a27890b1a6
commit
1f46bc1926
|
@ -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 {
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue