-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase grpc message send and receive size
- Loading branch information
1 parent
bc65726
commit 4602389
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
}) | ||
} |