helper/schema: don't skip deprecation check during validation

If an attribute was not wholly known, helper/schema was skipping the
`validateType` function which (among other things) returned deprecation
messages. This PR checks for deprecation before returning when skipping
validateType.
This commit is contained in:
Kristin Laemmert 2019-07-30 16:00:43 -04:00
parent 7e6b05a95f
commit bfd66083de
2 changed files with 21 additions and 0 deletions

View File

@ -1371,6 +1371,9 @@ func (m schemaMap) validate(
// The SDK has to allow the unknown value through initially, so that
// Required fields set via an interpolated value are accepted.
if !isWhollyKnown(raw) {
if schema.Deprecated != "" {
return []string{fmt.Sprintf("%q: [DEPRECATED] %s", k, schema.Deprecated)}, nil
}
return nil, nil
}

View File

@ -4510,6 +4510,24 @@ func TestSchemaMap_Validate(t *testing.T) {
Err: false,
},
"Unknown + Deprecation": {
Schema: map[string]*Schema{
"old_news": &Schema{
Type: TypeString,
Optional: true,
Deprecated: "please use 'new_news' instead",
},
},
Config: map[string]interface{}{
"old_news": hcl2shim.UnknownVariableValue,
},
Warnings: []string{
"\"old_news\": [DEPRECATED] please use 'new_news' instead",
},
},
"Required sub-resource field": {
Schema: map[string]*Schema{
"ingress": &Schema{