/
server_configureprovider.go
39 lines (27 loc) · 1.22 KB
/
server_configureprovider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package proto5server
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/internal/fromproto5"
"github.com/hashicorp/terraform-plugin-framework/internal/logging"
"github.com/hashicorp/terraform-plugin-framework/internal/toproto5"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
)
// ConfigureProvider satisfies the tfprotov5.ProviderServer interface.
func (s *Server) ConfigureProvider(ctx context.Context, proto5Req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
fwResp := &tfsdk.ConfigureProviderResponse{}
providerSchema, diags := s.FrameworkServer.ProviderSchema(ctx)
fwResp.Diagnostics.Append(diags...)
if fwResp.Diagnostics.HasError() {
return toproto5.ConfigureProviderResponse(ctx, fwResp), nil
}
fwReq, diags := fromproto5.ConfigureProviderRequest(ctx, proto5Req, providerSchema)
fwResp.Diagnostics.Append(diags...)
if fwResp.Diagnostics.HasError() {
return toproto5.ConfigureProviderResponse(ctx, fwResp), nil
}
s.FrameworkServer.ConfigureProvider(ctx, fwReq, fwResp)
return toproto5.ConfigureProviderResponse(ctx, fwResp), nil
}