Merge pull request #19114 from hashicorp/jbardin/provider-defaults
don't set defaults for deprecated or removed
This commit is contained in:
commit
47921bddb7
|
@ -115,6 +115,11 @@ func (s *GRPCProviderServer) PrepareProviderConfig(_ context.Context, req *proto
|
|||
return val, nil
|
||||
}
|
||||
|
||||
// this is deprecated, so don't set it
|
||||
if attrSchema.Deprecated != "" || attrSchema.Removed != "" {
|
||||
return val, nil
|
||||
}
|
||||
|
||||
// find a default value if it exists
|
||||
def, err := attrSchema.DefaultValue()
|
||||
if err != nil {
|
||||
|
@ -129,6 +134,7 @@ func (s *GRPCProviderServer) PrepareProviderConfig(_ context.Context, req *proto
|
|||
// create a cty.Value and make sure it's the correct type
|
||||
tmpVal := hcl2shim.HCL2ValueFromConfigValue(def)
|
||||
val, err = ctyconvert.Convert(tmpVal, val.Type())
|
||||
|
||||
return val, err
|
||||
})
|
||||
|
||||
|
|
|
@ -533,6 +533,23 @@ func TestPrepareProviderConfig(t *testing.T) {
|
|||
"foo": cty.StringVal("true"),
|
||||
}),
|
||||
},
|
||||
{
|
||||
Name: "test deprecated default",
|
||||
Schema: map[string]*schema.Schema{
|
||||
"foo": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Default: "do not use",
|
||||
Removed: "don't use this",
|
||||
},
|
||||
},
|
||||
ConfigVal: cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.NullVal(cty.String),
|
||||
}),
|
||||
ExpectConfig: cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.NullVal(cty.String),
|
||||
}),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
server := &GRPCProviderServer{
|
||||
|
|
Loading…
Reference in New Issue