Skip to content

Commit 710ed93

Browse files
committed
Addressed some PR comments
1 parent 0e23b3e commit 710ed93

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

internal/fwserver/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ package fwserver
66
import (
77
"context"
88
"fmt"
9-
"github.com/hashicorp/terraform-plugin-framework/action"
10-
actionschema "github.com/hashicorp/terraform-plugin-framework/action/schema"
119
"sync"
1210

11+
"github.com/hashicorp/terraform-plugin-framework/action"
12+
actionschema "github.com/hashicorp/terraform-plugin-framework/action/schema"
1313
"github.com/hashicorp/terraform-plugin-framework/datasource"
1414
"github.com/hashicorp/terraform-plugin-framework/diag"
1515
"github.com/hashicorp/terraform-plugin-framework/ephemeral"

internal/fwserver/server_listresource.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package fwserver
55

66
import (
77
"context"
8+
"github.com/hashicorp/terraform-plugin-go/tftypes"
89
"iter"
910

1011
"github.com/hashicorp/terraform-plugin-framework/diag"
@@ -87,8 +88,10 @@ func (s *Server) ListResource(ctx context.Context, fwReq *ListRequest, fwStream
8788
listResource := fwReq.ListResource
8889

8990
if fwReq.Config == nil {
90-
fwStream.Results = NoListResults
91-
return
91+
fwReq.Config = &tfsdk.Config{
92+
Raw: tftypes.NewValue(fwReq.ResourceSchema.Type().TerraformType(ctx), nil),
93+
Schema: fwReq.ResourceSchema,
94+
}
9295
}
9396

9497
req := list.ListRequest{

internal/fwserver/server_listresource_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ func TestServerListResource(t *testing.T) {
8989
},
9090
expectedStreamEvents: []fwserver.ListResult{},
9191
},
92+
"success-with-nil-results": {
93+
server: &fwserver.Server{
94+
Provider: &testprovider.Provider{},
95+
},
96+
request: &fwserver.ListRequest{
97+
Config: &tfsdk.Config{},
98+
ListResource: &testprovider.ListResource{
99+
ListMethod: func(ctx context.Context, req list.ListRequest, resp *list.ListResultsStream) {
100+
// Do nothing, so that resp.Results is nil
101+
},
102+
},
103+
},
104+
expectedStreamEvents: []fwserver.ListResult{},
105+
},
92106
"success-with-multiple-results": {
93107
server: &fwserver.Server{
94108
Provider: &testprovider.Provider{},

0 commit comments

Comments
 (0)