File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,13 @@ import (
2222// - Validation: Schema-based or entire configuration via
2323// ListResourceWithConfigValidators or ListResourceWithValidateConfig.
2424type ListResource interface {
25- // Metadata should return the full name of the list resource such as
26- // examplecloud_thing. This name should match the full name of the managed
27- // resource to be listed; otherwise, the GetMetadata RPC will return an
28- // error diagnostic.
29- //
30- // The method signature is intended to be compatible with the Metadata
31- // method signature in the Resource interface. One implementation of
32- // Metadata can satisfy both interfaces.
33- Metadata (context.Context , resource.MetadataRequest , * resource.MetadataResponse )
25+ // A single provider-defined type can implement the
26+ // Create-Read-Update-Delete (CRUD) operations ([resource.Resource]) and
27+ // the List (L) operation ([list.ListResource]). The
28+ // [resource.ResourceMetadata] interface is embedded in both interfaces.
29+ // This allows a single implementation of `Metadata()` to satisfy both
30+ // interfaces without code duplication.
31+ resource.ResourceMetadata
3432
3533 // ListResourceConfigSchema should return the schema for list blocks.
3634 ListResourceConfigSchema (context.Context , ListResourceSchemaRequest , * ListResourceSchemaResponse )
Original file line number Diff line number Diff line change @@ -26,9 +26,7 @@ import (
2626// Although not required, it is conventional for resources to implement the
2727// ResourceWithImportState interface.
2828type Resource interface {
29- // Metadata should return the full name of the resource, such as
30- // examplecloud_thing.
31- Metadata (context.Context , MetadataRequest , * MetadataResponse )
29+ ResourceMetadata
3230
3331 // Schema should return the schema for this resource.
3432 Schema (context.Context , SchemaRequest , * SchemaResponse )
@@ -57,6 +55,12 @@ type Resource interface {
5755 Delete (context.Context , DeleteRequest , * DeleteResponse )
5856}
5957
58+ type ResourceMetadata interface {
59+ // Metadata should return the full name of the resource, such as
60+ // examplecloud_thing.
61+ Metadata (context.Context , MetadataRequest , * MetadataResponse )
62+ }
63+
6064// ResourceWithConfigure is an interface type that extends Resource to
6165// include a method which the framework will automatically call so provider
6266// developers have the opportunity to setup any necessary provider-level data
You can’t perform that action at this time.
0 commit comments