-
Notifications
You must be signed in to change notification settings - Fork 99
ListResource: revisit handling of null ListResult fields
#1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7dce0b7
65651f6
ce2bb12
3e5c9f7
9c0fecc
93602b7
3774a18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,20 @@ type ListRequest struct { | |
| ResourceIdentitySchema fwschema.Schema | ||
| } | ||
|
|
||
| // NewListResult creates a new [ListResult] with convenient defaults | ||
| // for each field. | ||
| func (r ListRequest) NewListResult() ListResult { | ||
| identity := &tfsdk.ResourceIdentity{Schema: r.ResourceIdentitySchema} | ||
| resource := &tfsdk.Resource{Schema: r.ResourceSchema} | ||
|
|
||
| return ListResult{ | ||
| DisplayName: "", | ||
| Resource: resource, | ||
| Identity: identity, | ||
| Diagnostics: diag.Diagnostics{}, | ||
| } | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future consideration: Should we eventually add a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe! If it's a diagnostics-only response, then we have Very open to 💡 to refine that API. |
||
| // ListResultsStream represents a streaming response to a [ListRequest]. An | ||
| // instance of this struct is supplied as an argument to the provider's | ||
| // [ListResource.List] function. The provider should set a Results iterator | ||
|
|
@@ -120,9 +134,20 @@ type ListResultsStream struct { | |
| } | ||
|
|
||
| // NoListResults is an iterator that pushes zero results. | ||
| var NoListResults = func(func(ListResult) bool) {} | ||
| var NoListResults = func(push func(ListResult) bool) {} | ||
|
|
||
| // ListResultsStreamDiagnostics returns a function that yields a single | ||
| // [ListResult] with the given Diagnostics | ||
| func ListResultsStreamDiagnostics(diags diag.Diagnostics) iter.Seq[ListResult] { | ||
| return func(push func(ListResult) bool) { | ||
| if !push(ListResult{Diagnostics: diags}) { | ||
| return | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // ListResult represents a listed managed resource instance. | ||
| // ListResult represents a listed managed resource instance. For convenience, | ||
| // create new values using [NewListResult] instead of struct literals. | ||
| type ListResult struct { | ||
| // Identity is the identity of the managed resource instance. | ||
| // | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.