-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
factory.go
33 lines (25 loc) · 936 Bytes
/
factory.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
package provider
import (
"context"
"github.com/cloudposse/terraform-provider-awsutils/internal/provider/fwprovider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
)
// ProtoV5ProviderServerFactory returns a muxed terraform-plugin-go protocol v5 provider factory function.
// This factory function is suitable for use with the terraform-plugin-go Serve function.
func ProtoV5ProviderServerFactory(ctx context.Context) (func() tfprotov5.ProviderServer, error) {
primary, err := New(ctx)
if err != nil {
return nil, err
}
servers := []func() tfprotov5.ProviderServer{
primary.GRPCProvider,
providerserver.NewProtocol5(fwprovider.New(primary)),
}
muxServer, err := tf5muxserver.NewMuxServer(ctx, servers...)
if err != nil {
return nil, err
}
return muxServer.ProviderServer, nil
}