Skip to content

Commit 0714252

Browse files
committed
link to more complete SDKv2 example
1 parent 58b63d4 commit 0714252

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

content/terraform-plugin-framework/v1.16.x/docs/plugin/framework/list-resources/non-framework-resource.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ func (r *ThingListResource) RawV5Schemas(ctx context.Context, req list.RawV5Sche
3636
/* ... */
3737
}
3838
}
39-
```
39+
```
40+
41+
For a more complete example of implementing a list resource with an SDKv2 resource, refer to the [SDKv2 List documentation](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/list).

content/terraform-plugin-sdk/v2.38.x/docs/plugin/sdkv2/resources/list.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ In this example, the list method on the resource `examplecloud_thing` is defined
5252

5353
```go
5454
// Some list.ListResource interface methods are omitted for brevity.
55+
56+
import (
57+
"context"
58+
59+
"github.com/hashicorp/terraform-plugin-framework/list"
60+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
61+
)
62+
5563
type ThingListResource struct{}
5664

5765
func (r *ThingListResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
5866
resp.TypeName = "examplecloud_thing"
5967
}
6068

6169
func (r *ThingListResource) RawV5Schemas(ctx context.Context, req list.RawV5SchemaRequest, resp *list.RawV5SchemaResponse) {
70+
// Where `resourceThing` returns an SDKv2 `schema.Resource` instance
6271
thingResource := resourceThing()
6372

6473
resp.ProtoV5Schema = thingResource.ProtoSchema(ctx)()
@@ -69,8 +78,9 @@ func (r *ThingListResource) List(ctx context.Context, req list.ListRequest, stre
6978
var data ThingListResourceModel
7079

7180
// Read list config data into the model
72-
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
73-
if resp.Diagnostics.HasError() {
81+
diags := request.Config.Get(ctx, &data)
82+
if diags.HasError() {
83+
stream.Results = list.ListResultsStreamDiagnostics(diags)
7484
return
7585
}
7686

0 commit comments

Comments
 (0)