@@ -2,6 +2,7 @@ package provider
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
6
7
"github.com/hashicorp/terraform-plugin-framework/datasource"
7
8
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -45,7 +46,20 @@ func (d *NamespaceDataSource) Schema(_ context.Context, _ datasource.SchemaReque
45
46
}
46
47
47
48
func (d * NamespaceDataSource ) Configure (_ context.Context , req datasource.ConfigureRequest , resp * datasource.ConfigureResponse ) {
48
- d .client = ConfigureClient (req , resp )
49
+ if req .ProviderData == nil {
50
+ return
51
+ }
52
+
53
+ client , ok := req .ProviderData .(* client.Client )
54
+ if ! ok {
55
+ resp .Diagnostics .AddError (
56
+ "Unexpected Data Source Configure Type" ,
57
+ fmt .Sprintf ("Expected *client.Client, got: %T." , req .ProviderData ),
58
+ )
59
+ return
60
+ }
61
+
62
+ d .client = client
49
63
}
50
64
51
65
func (d * NamespaceDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
@@ -56,6 +70,14 @@ func (d *NamespaceDataSource) Read(ctx context.Context, req datasource.ReadReque
56
70
return
57
71
}
58
72
73
+ if d .client == nil {
74
+ resp .Diagnostics .AddError (
75
+ "Client not configured" ,
76
+ "The provider client is not properly configured. Please report this issue to the provider developers." ,
77
+ )
78
+ return
79
+ }
80
+
59
81
namespaceResp , err := d .client .NamespaceService .GetNamespace (ctx , & pb.GetNamespaceRequest {
60
82
Id : data .ID .ValueString (),
61
83
})
0 commit comments