Skip to content

Commit

Permalink
Merge pull request #22262 from hashicorp/mildwonkey/b-deprecation-war…
Browse files Browse the repository at this point in the history
…nings

helper/schema: don't skip deprecation check during validation
  • Loading branch information
teamterraform authored Jul 30, 2019
2 parents ad8ff53 + bfd6608 commit 176f790
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
18 changes: 18 additions & 0 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 176f790

Please sign in to comment.