Skip to content

Commit 0d47215

Browse files
authored
Minor improvements to Framework and SDKv2 List Docs (#1494)
### What - Framework's list documentation on non-framework resources links to a more complete example in the SDKv2 documentation - SDKv2's list documentation received some minor fixes in the example as well as further comments and explicit imports to reduce confusion ---------- ### Merge Checklist _If items do not apply to your changes, add (N/A) and mark them as complete._ #### Pull Request - [ ] Description links to related pull requests or issues, if any. #### Content - [ ] You added redirects to `content/terraform-docs-common/redirects.jsonc` for moved, renamed, or deleted pages **across all affected versions**. Refer to [Redirects](https://github.com/hashicorp/web-unified-docs/blob/main/docs/content-guide/redirects.md#example-redirects) for examples and guidance. - [ ] Links to related content where appropriate (e.g., CLI, language, API endpoints, permissions, etc.). - [ ] Pages with related content are updated and link to this content when appropriate. - [ ] Sidebar navigation files have been updated for added, deleted, reordered, or renamed pages. - [ ] New pages have metadata (page name and description) at the top. - [ ] New images are 2048 px wide. They have HashiCorp standard annotation color (#F92672) and format (rectangle with rounded corners), blurred sensitive details (e.g. credentials, usernames, user icons), and descriptive alt text in the markdown for accessibility. - [ ] New code blocks have the correct syntax and line breaks to eliminate horizontal scroll bars. - [ ] UI elements (button names, page names, etc.) are bolded. - [ ] The Vercel website preview successfully deployed. #### Reviews - [ ] I or someone else reviewed the content for technical accuracy. - [ ] I or someone else reviewed the content for typos, punctuation, spelling, and grammar.
2 parents 1794111 + 0714252 commit 0d47215

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)