@@ -2,23 +2,37 @@ package plugin
22
33import (
44 "context"
5+ "errors"
6+ "net/rpc"
57
68 plugin "github.com/hashicorp/go-plugin"
79 "google.golang.org/grpc"
810
911 proto "github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5"
1012)
1113
12- // GRPCProviderPlugin implements plugin.GRPCPlugin for the go-plugin package.
14+ var (
15+ _ plugin.GRPCPlugin = (* gRPCProviderPlugin )(nil )
16+ _ plugin.Plugin = (* gRPCProviderPlugin )(nil )
17+ )
18+
19+ // gRPCProviderPlugin implements plugin.GRPCPlugin and plugin.Plugin for the go-plugin package.
20+ // the only real implementation is GRPCSServer, the other methods are only satisfied
21+ // for compatibility with go-plugin
1322type gRPCProviderPlugin struct {
14- plugin.Plugin
1523 GRPCProvider func () proto.ProviderServer
1624}
1725
18- // this exists only to satisfy the go-plugin.GRPCPlugin interface
19- // that interface should likely be split
20- func (p * gRPCProviderPlugin ) GRPCClient (ctx context.Context , broker * plugin.GRPCBroker , c * grpc.ClientConn ) (interface {}, error ) {
21- return nil , nil
26+ func (p * gRPCProviderPlugin ) Server (* plugin.MuxBroker ) (interface {}, error ) {
27+ return nil , errors .New ("terraform-plugin-sdk only implements grpc servers" )
28+ }
29+
30+ func (p * gRPCProviderPlugin ) Client (* plugin.MuxBroker , * rpc.Client ) (interface {}, error ) {
31+ return nil , errors .New ("terraform-plugin-sdk only implements grpc servers" )
32+ }
33+
34+ func (p * gRPCProviderPlugin ) GRPCClient (context.Context , * plugin.GRPCBroker , * grpc.ClientConn ) (interface {}, error ) {
35+ return nil , errors .New ("terraform-plugin-sdk only implements grpc servers" )
2236}
2337
2438func (p * gRPCProviderPlugin ) GRPCServer (broker * plugin.GRPCBroker , s * grpc.Server ) error {
0 commit comments