Skip to content

Commit 4602389

Browse files
committed
Increase grpc message send and receive size
1 parent bc65726 commit 4602389

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ go 1.14
44

55
require (
66
github.com/cenkalti/backoff v2.1.1+incompatible
7+
github.com/hashicorp/go-plugin v1.3.0
78
github.com/hashicorp/hcl/v2 v2.6.0
89
github.com/hashicorp/terraform v0.12.29
10+
github.com/hashicorp/terraform-plugin-go v0.1.0
911
github.com/hashicorp/terraform-plugin-sdk/v2 v2.3.0
1012
github.com/icza/dyno v0.0.0-20180601094105-0c96289f9585
1113
github.com/mitchellh/go-homedir v1.1.0
1214
github.com/stretchr/testify v1.5.1
1315
github.com/zclconf/go-cty v1.2.1
1416
github.com/zclconf/go-cty-yaml v1.0.1
17+
google.golang.org/grpc v1.32.0
1518
gopkg.in/yaml.v2 v2.2.8
1619
k8s.io/api v0.18.12
1720
k8s.io/apimachinery v0.18.12

main.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,45 @@ package main
22

33
import (
44
kubernetes "github.com/gavinbunney/terraform-provider-kubectl/kubernetes"
5+
goplugin "github.com/hashicorp/go-plugin"
6+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
7+
tf5server "github.com/hashicorp/terraform-plugin-go/tfprotov5/server"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
59
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
10+
"google.golang.org/grpc"
611
)
712

813
func main() {
914
plugin.Serve(&plugin.ServeOpts{
10-
ProviderFunc: kubernetes.Provider})
15+
GRPCProviderFunc: func() tfprotov5.ProviderServer {
16+
return schema.NewGRPCProviderServer(kubernetes.Provider())
17+
},
18+
})
19+
20+
opts := &plugin.ServeOpts{}
21+
grpcProviderFunc := func() tfprotov5.ProviderServer {
22+
return schema.NewGRPCProviderServer(kubernetes.Provider())
23+
}
24+
25+
// taken from github.com/hashicorp/terraform-plugin-sdk/v2@v2.3.0/plugin/serve.go
26+
// configured to allow larger message sizes than 4mb
27+
goplugin.Serve(&goplugin.ServeConfig{
28+
HandshakeConfig: plugin.Handshake,
29+
VersionedPlugins: map[int]goplugin.PluginSet{
30+
5: {
31+
plugin.ProviderPluginName: &tf5server.GRPCProviderPlugin{
32+
GRPCProvider: func() tfprotov5.ProviderServer {
33+
return grpcProviderFunc()
34+
},
35+
},
36+
},
37+
},
38+
GRPCServer: func(opts []grpc.ServerOption) *grpc.Server {
39+
return grpc.NewServer(append(opts,
40+
grpc.MaxSendMsgSize(64<<20 /* 64MB */),
41+
grpc.MaxRecvMsgSize(64<<20 /* 64MB */))...)
42+
},
43+
Logger: opts.Logger,
44+
Test: opts.TestConfig,
45+
})
1146
}

0 commit comments

Comments
 (0)