-
Notifications
You must be signed in to change notification settings - Fork 107
/
main.go
40 lines (37 loc) · 1.23 KB
/
main.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
40
package main
import (
kubernetes "github.com/gavinbunney/terraform-provider-kubectl/kubernetes"
goplugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"google.golang.org/grpc"
)
func main() {
opts := &plugin.ServeOpts{}
grpcProviderFunc := func() tfprotov5.ProviderServer {
return schema.NewGRPCProviderServer(kubernetes.Provider())
}
// taken from github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go
// configured to allow larger message sizes than 4mb
goplugin.Serve(&goplugin.ServeConfig{
HandshakeConfig: plugin.Handshake,
VersionedPlugins: map[int]goplugin.PluginSet{
5: {
plugin.ProviderPluginName: &tf5server.GRPCProviderPlugin{
GRPCProvider: func() tfprotov5.ProviderServer {
return grpcProviderFunc()
},
},
},
},
GRPCServer: func(opts []grpc.ServerOption) *grpc.Server {
return grpc.NewServer(append(opts,
grpc.MaxSendMsgSize(64<<20 /* 64MB */),
grpc.MaxRecvMsgSize(64<<20 /* 64MB */))...)
},
Logger: opts.Logger,
Test: opts.TestConfig,
})
}