diff --git a/helper/schema/data_source_resource_shim.go b/helper/schema/data_source_resource_shim.go index 5a03d2d80..df9a3c034 100644 --- a/helper/schema/data_source_resource_shim.go +++ b/helper/schema/data_source_resource_shim.go @@ -32,7 +32,7 @@ func DataSourceResourceShim(name string, dataSource *Resource) *Resource { // FIXME: Link to some further docs either on the website or in the // changelog, once such a thing exists. - dataSource.deprecationMessage = fmt.Sprintf( + dataSource.Deprecated = fmt.Sprintf( "using %s as a resource is deprecated; consider using the data source instead", name, ) diff --git a/helper/schema/resource.go b/helper/schema/resource.go index 8f726bfbe..f96b2491d 100644 --- a/helper/schema/resource.go +++ b/helper/schema/resource.go @@ -124,9 +124,7 @@ type Resource struct { Importer *ResourceImporter // If non-empty, this string is emitted as a warning during Validate. - // This is a private interface for now, for use by DataSourceResourceShim, - // and not for general use. (But maybe later...) - deprecationMessage string + Deprecated string // Timeouts allow users to specify specific time durations in which an // operation should time out, to allow them to extend an action to suit their @@ -269,8 +267,8 @@ func (r *Resource) Diff( func (r *Resource) Validate(c *terraform.ResourceConfig) ([]string, []error) { warns, errs := schemaMap(r.Schema).Validate(c) - if r.deprecationMessage != "" { - warns = append(warns, r.deprecationMessage) + if r.Deprecated != "" { + warns = append(warns, r.Deprecated) } return warns, errs diff --git a/helper/schema/resource_test.go b/helper/schema/resource_test.go index 553533b15..992c1aa04 100644 --- a/helper/schema/resource_test.go +++ b/helper/schema/resource_test.go @@ -850,6 +850,20 @@ func TestResourceInternalValidate(t *testing.T) { false, true, }, + 14: { // Deprecated resource + &Resource{ + Read: func(d *ResourceData, meta interface{}) error { return nil }, + Schema: map[string]*Schema{ + "goo": &Schema{ + Type: TypeInt, + Optional: true, + }, + }, + Deprecated: "This resource has been deprecated.", + }, + true, + true, + }, } for i, tc := range cases {