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:
parent
7e6b05a95f
commit
bfd66083de
|
@ -1371,6 +1371,9 @@ func (m schemaMap) validate(
|
||||||
// The SDK has to allow the unknown value through initially, so that
|
// The SDK has to allow the unknown value through initially, so that
|
||||||
// Required fields set via an interpolated value are accepted.
|
// Required fields set via an interpolated value are accepted.
|
||||||
if !isWhollyKnown(raw) {
|
if !isWhollyKnown(raw) {
|
||||||
|
if schema.Deprecated != "" {
|
||||||
|
return []string{fmt.Sprintf("%q: [DEPRECATED] %s", k, schema.Deprecated)}, nil
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4510,6 +4510,24 @@ func TestSchemaMap_Validate(t *testing.T) {
|
||||||
Err: false,
|
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": {
|
"Required sub-resource field": {
|
||||||
Schema: map[string]*Schema{
|
Schema: map[string]*Schema{
|
||||||
"ingress": &Schema{
|
"ingress": &Schema{
|
||||||
|
|
Loading…
Reference in New Issue