get.porter.sh/porter@v1.3.0/pkg/secrets/pluginstore/plugin.go (about) 1 package pluginstore 2 3 import ( 4 "context" 5 6 "get.porter.sh/porter/pkg/portercontext" 7 "get.porter.sh/porter/pkg/secrets/plugins" 8 "get.porter.sh/porter/pkg/secrets/plugins/proto" 9 "github.com/hashicorp/go-plugin" 10 "google.golang.org/grpc" 11 ) 12 13 var _ plugin.GRPCPlugin = Plugin{} 14 15 // Plugin is the shared implementation of a storage plugin wrapper. 16 type Plugin struct { 17 plugin.Plugin 18 impl plugins.SecretsProtocol 19 context *portercontext.Context 20 } 21 22 // NewPlugin creates an instance of a storage plugin. 23 func NewPlugin(c *portercontext.Context, impl plugins.SecretsProtocol) Plugin { 24 return Plugin{ 25 context: c, 26 impl: impl, 27 } 28 } 29 30 func (p Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { 31 impl := NewServer(p.context, p.impl) 32 proto.RegisterSecretsProtocolServer(s, impl) 33 return nil 34 } 35 36 func (p Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, conn *grpc.ClientConn) (interface{}, error) { 37 return NewClient(proto.NewSecretsProtocolClient(conn)), nil 38 }