Skip to content

Commit

Permalink
Increase grpc message send and receive size
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney committed Dec 1, 2020
1 parent bc65726 commit 4602389
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ go 1.14

require (
github.com/cenkalti/backoff v2.1.1+incompatible
github.com/hashicorp/go-plugin v1.3.0
github.com/hashicorp/hcl/v2 v2.6.0
github.com/hashicorp/terraform v0.12.29
github.com/hashicorp/terraform-plugin-go v0.1.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.3.0
github.com/icza/dyno v0.0.0-20180601094105-0c96289f9585
github.com/mitchellh/go-homedir v1.1.0
github.com/stretchr/testify v1.5.1
github.com/zclconf/go-cty v1.2.1
github.com/zclconf/go-cty-yaml v1.0.1
google.golang.org/grpc v1.32.0
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.18.12
k8s.io/apimachinery v0.18.12
Expand Down
37 changes: 36 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,45 @@ package main

import (
kubernetes "github.com/gavinbunney/terraform-provider-kubectl/kubernetes"
goplugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
tf5server "github.com/hashicorp/terraform-plugin-go/tfprotov5/server"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"google.golang.org/grpc"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: kubernetes.Provider})
GRPCProviderFunc: func() tfprotov5.ProviderServer {
return schema.NewGRPCProviderServer(kubernetes.Provider())
},
})

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,
})
}

0 comments on commit 4602389

Please sign in to comment.