Skip to content

Commit a19df43

Browse files
authored
Add tfprotov{5,6}.NoListResults for convenience (#529)
1 parent 53272ee commit a19df43

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

tfprotov5/list_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type ListResourceServerStream struct {
5353
Results iter.Seq[ListResourceResult]
5454
}
5555

56+
// NoListResults is a convenient value to return when there are no list results.
57+
var NoListResults = func(func(ListResourceResult) bool) {}
58+
5659
type ListResourceResult struct { // TODO: propose rename in protocol: ListResource_Event -> ListResource_Result
5760
// DisplayName is the display name of the resource. This is a ...
5861
DisplayName string

tfprotov5/tf5server/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,7 @@ func (s *server) ValidateListResourceConfig(ctx context.Context, protoReq *tfplu
12101210

12111211
ctx = tf5serverlogging.DownstreamRequest(ctx)
12121212

1213-
// TODO: Remove this check and error in preference of
1214-
// s.downstream.ValidateListResourceConfig below once ProviderServer interface
1213+
// TODO: Remove this check and error once ProviderServer interface
12151214
// implements this RPC method.
12161215
// nolint:staticcheck
12171216
listResourceServer, ok := s.downstream.(tfprotov5.ProviderServerWithListResource)

tfprotov6/list_resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type ListResourceServerStream struct {
5353
Results iter.Seq[ListResourceResult]
5454
}
5555

56+
// NoListResults is a convenient value to return when there are no list results.
57+
var NoListResults = func(func(ListResourceResult) bool) {}
58+
5659
type ListResourceResult struct { // TODO: propose rename in protocol: ListResource_Event -> ListResource_Result
5760
// DisplayName is the display name of the resource. This is a ...
5861
DisplayName string

tfprotov6/tf6server/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,7 @@ func (s *server) ListResource(protoReq *tfplugin6.ListResource_Request, protoStr
12641264

12651265
ctx = tf6serverlogging.DownstreamRequest(ctx)
12661266

1267-
// TODO: Remove this check and error in preference of
1268-
// s.downstream.ValidateListResourceConfig below once ProviderServer interface
1267+
// TODO: Remove this check and error once ProviderServer interface
12691268
// implements this RPC method.
12701269
// nolint:staticcheck
12711270
downstream, ok := s.downstream.(tfprotov6.ProviderServerWithListResource)

0 commit comments

Comments
 (0)