mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 05:25:40 +00:00
update plugins to work with updated go-plugin (#1308)
* update plugins to work with updated go-plugin Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
@@ -18,6 +18,7 @@ package framework
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
proto "github.com/heptio/velero/pkg/plugin/generated"
|
||||
@@ -32,12 +33,12 @@ type BackupItemActionPlugin struct {
|
||||
}
|
||||
|
||||
// GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.
|
||||
func (p *BackupItemActionPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, c, newBackupItemActionGRPCClient), nil
|
||||
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, clientConn, newBackupItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
// GRPCServer registers a BackupItemAction gRPC server.
|
||||
func (p *BackupItemActionPlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterBackupItemActionServer(s, &BackupItemActionGRPCServer{mux: p.serverMux})
|
||||
func (p *BackupItemActionPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
|
||||
proto.RegisterBackupItemActionServer(server, &BackupItemActionGRPCServer{mux: p.serverMux})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package framework
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
proto "github.com/heptio/velero/pkg/plugin/generated"
|
||||
@@ -32,12 +33,12 @@ type BlockStorePlugin struct {
|
||||
}
|
||||
|
||||
// GRPCClient returns a BlockStore gRPC client.
|
||||
func (p *BlockStorePlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, c, newBlockStoreGRPCClient), nil
|
||||
func (p *BlockStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, clientConn, newBlockStoreGRPCClient), nil
|
||||
}
|
||||
|
||||
// GRPCServer registers a BlockStore gRPC server.
|
||||
func (p *BlockStorePlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterBlockStoreServer(s, &BlockStoreGRPCServer{mux: p.serverMux})
|
||||
func (p *BlockStorePlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
|
||||
proto.RegisterBlockStoreServer(server, &BlockStoreGRPCServer{mux: p.serverMux})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package framework
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
proto "github.com/heptio/velero/pkg/plugin/generated"
|
||||
@@ -32,13 +33,13 @@ type ObjectStorePlugin struct {
|
||||
}
|
||||
|
||||
// GRPCClient returns an ObjectStore gRPC client.
|
||||
func (p *ObjectStorePlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, c, newObjectStoreGRPCClient), nil
|
||||
func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, clientConn, newObjectStoreGRPCClient), nil
|
||||
|
||||
}
|
||||
|
||||
// GRPCServer registers an ObjectStore gRPC server.
|
||||
func (p *ObjectStorePlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterObjectStoreServer(s, &ObjectStoreGRPCServer{mux: p.serverMux})
|
||||
func (p *ObjectStorePlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
|
||||
proto.RegisterObjectStoreServer(server, &ObjectStoreGRPCServer{mux: p.serverMux})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ func NewPluginListerPlugin(impl PluginLister) *PluginListerPlugin {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// GRPCClient returns a PluginLister gRPC client.
|
||||
func (p *PluginListerPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return &PluginListerGRPCClient{grpcClient: proto.NewPluginListerClient(c)}, nil
|
||||
func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
return &PluginListerGRPCClient{grpcClient: proto.NewPluginListerClient(clientConn)}, nil
|
||||
}
|
||||
|
||||
// PluginListerGRPCClient implements PluginLister and uses a gRPC client to make calls to the plugin server.
|
||||
@@ -106,8 +106,8 @@ func (c *PluginListerGRPCClient) ListPlugins() ([]PluginIdentifier, error) {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// GRPCServer registers a PluginLister gRPC server.
|
||||
func (p *PluginListerPlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterPluginListerServer(s, &PluginListerGRPCServer{impl: p.impl})
|
||||
func (p *PluginListerPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
|
||||
proto.RegisterPluginListerServer(server, &PluginListerGRPCServer{impl: p.impl})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
39
pkg/plugin/framework/plugin_types_test.go
Normal file
39
pkg/plugin/framework/plugin_types_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2019 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package framework
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPluginImplementationsAreGRPCPlugins(t *testing.T) {
|
||||
pluginImpls := []interface{}{
|
||||
new(BlockStorePlugin),
|
||||
new(BackupItemActionPlugin),
|
||||
new(ObjectStorePlugin),
|
||||
new(PluginListerPlugin),
|
||||
new(RestoreItemActionPlugin),
|
||||
}
|
||||
|
||||
for _, impl := range pluginImpls {
|
||||
_, ok := impl.(plugin.GRPCPlugin)
|
||||
assert.True(t, ok, "plugin implementation %T does not implement the go-plugin.GRPCPlugin interface", impl)
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package framework
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
proto "github.com/heptio/velero/pkg/plugin/generated"
|
||||
@@ -32,12 +33,12 @@ type RestoreItemActionPlugin struct {
|
||||
}
|
||||
|
||||
// GRPCClient returns a RestoreItemAction gRPC client.
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, c, newRestoreItemActionGRPCClient), nil
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
return newClientDispenser(p.clientLogger, clientConn, newRestoreItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
// GRPCServer registers a RestoreItemAction gRPC server.
|
||||
func (p *RestoreItemActionPlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterRestoreItemActionServer(s, &RestoreItemActionGRPCServer{mux: p.serverMux})
|
||||
func (p *RestoreItemActionPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
|
||||
proto.RegisterRestoreItemActionServer(server, &RestoreItemActionGRPCServer{mux: p.serverMux})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user