Merge pull request #22262 from hashicorp/mildwonkey/b-deprecation-warnings

helper/schema: don't skip deprecation check during validation
This commit is contained in:
The Terraform Team 2019-07-30 21:27:51 +01:00 committed by GitHub
commit 176f790323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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{