mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-19 05:36:08 +00:00
convert restorers to plugins
Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
@@ -8,10 +8,10 @@ It is generated from these files:
|
||||
BackupItemAction.proto
|
||||
BlockStore.proto
|
||||
ObjectStore.proto
|
||||
RestoreItemAction.proto
|
||||
Shared.proto
|
||||
|
||||
It has these top-level messages:
|
||||
AppliesToResponse
|
||||
ExecuteRequest
|
||||
ExecuteResponse
|
||||
ResourceIdentifier
|
||||
@@ -36,8 +36,11 @@ It has these top-level messages:
|
||||
DeleteObjectRequest
|
||||
CreateSignedURLRequest
|
||||
CreateSignedURLResponse
|
||||
RestoreExecuteRequest
|
||||
RestoreExecuteResponse
|
||||
Empty
|
||||
InitRequest
|
||||
AppliesToResponse
|
||||
*/
|
||||
package generated
|
||||
|
||||
@@ -61,54 +64,6 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type AppliesToResponse struct {
|
||||
IncludedNamespaces []string `protobuf:"bytes,1,rep,name=includedNamespaces" json:"includedNamespaces,omitempty"`
|
||||
ExcludedNamespaces []string `protobuf:"bytes,2,rep,name=excludedNamespaces" json:"excludedNamespaces,omitempty"`
|
||||
IncludedResources []string `protobuf:"bytes,3,rep,name=includedResources" json:"includedResources,omitempty"`
|
||||
ExcludedResources []string `protobuf:"bytes,4,rep,name=excludedResources" json:"excludedResources,omitempty"`
|
||||
Selector string `protobuf:"bytes,5,opt,name=selector" json:"selector,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) Reset() { *m = AppliesToResponse{} }
|
||||
func (m *AppliesToResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*AppliesToResponse) ProtoMessage() {}
|
||||
func (*AppliesToResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *AppliesToResponse) GetIncludedNamespaces() []string {
|
||||
if m != nil {
|
||||
return m.IncludedNamespaces
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetExcludedNamespaces() []string {
|
||||
if m != nil {
|
||||
return m.ExcludedNamespaces
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetIncludedResources() []string {
|
||||
if m != nil {
|
||||
return m.IncludedResources
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetExcludedResources() []string {
|
||||
if m != nil {
|
||||
return m.ExcludedResources
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetSelector() string {
|
||||
if m != nil {
|
||||
return m.Selector
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ExecuteRequest struct {
|
||||
Item []byte `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
|
||||
Backup []byte `protobuf:"bytes,2,opt,name=backup,proto3" json:"backup,omitempty"`
|
||||
@@ -117,7 +72,7 @@ type ExecuteRequest struct {
|
||||
func (m *ExecuteRequest) Reset() { *m = ExecuteRequest{} }
|
||||
func (m *ExecuteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ExecuteRequest) ProtoMessage() {}
|
||||
func (*ExecuteRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
func (*ExecuteRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *ExecuteRequest) GetItem() []byte {
|
||||
if m != nil {
|
||||
@@ -141,7 +96,7 @@ type ExecuteResponse struct {
|
||||
func (m *ExecuteResponse) Reset() { *m = ExecuteResponse{} }
|
||||
func (m *ExecuteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ExecuteResponse) ProtoMessage() {}
|
||||
func (*ExecuteResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
func (*ExecuteResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *ExecuteResponse) GetItem() []byte {
|
||||
if m != nil {
|
||||
@@ -167,7 +122,7 @@ type ResourceIdentifier struct {
|
||||
func (m *ResourceIdentifier) Reset() { *m = ResourceIdentifier{} }
|
||||
func (m *ResourceIdentifier) String() string { return proto.CompactTextString(m) }
|
||||
func (*ResourceIdentifier) ProtoMessage() {}
|
||||
func (*ResourceIdentifier) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||
func (*ResourceIdentifier) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
|
||||
func (m *ResourceIdentifier) GetGroup() string {
|
||||
if m != nil {
|
||||
@@ -198,7 +153,6 @@ func (m *ResourceIdentifier) GetName() string {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*AppliesToResponse)(nil), "generated.AppliesToResponse")
|
||||
proto.RegisterType((*ExecuteRequest)(nil), "generated.ExecuteRequest")
|
||||
proto.RegisterType((*ExecuteResponse)(nil), "generated.ExecuteResponse")
|
||||
proto.RegisterType((*ResourceIdentifier)(nil), "generated.ResourceIdentifier")
|
||||
@@ -312,28 +266,23 @@ var _BackupItemAction_serviceDesc = grpc.ServiceDesc{
|
||||
func init() { proto.RegisterFile("BackupItemAction.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 366 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcb, 0x4e, 0xeb, 0x30,
|
||||
0x10, 0x86, 0x95, 0xde, 0xce, 0xc9, 0x9c, 0xea, 0xb4, 0xb5, 0x50, 0x15, 0xa2, 0x22, 0x55, 0x59,
|
||||
0x75, 0x81, 0xb2, 0x28, 0x4b, 0x58, 0x50, 0xa4, 0x0a, 0x75, 0xc3, 0xc2, 0xf0, 0x02, 0x69, 0x32,
|
||||
0x94, 0x88, 0xc4, 0x36, 0xb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 0xea, 0xca, 0xa8, 0x73, 0xe5, 0x8f, 0x30, 0x8a, 0x92, 0x24, 0x35, 0xee, 0x47,
|
||||
0x99, 0xd9, 0x44, 0xe9, 0xc4, 0xbf, 0xe5, 0x55, 0xd8, 0x6c, 0x21, 0xac, 0xdf, 0xbb, 0x49, 0x90,
|
||||
0xe9, 0xf4, 0x35, 0x45, 0x49, 0x4f, 0xab, 0x82, 0x3d, 0x90, 0x36, 0x46, 0x2e, 0xa0, 0xbf, 0x93,
|
||||
0xbc, 0x10, 0xf6, 0x9f, 0x2e, 0x2d, 0x03, 0x33, 0xb5, 0xac, 0x58, 0xfb, 0x6a, 0x97, 0x36, 0x31,
|
||||
0x99, 0x81, 0xcb, 0x6a, 0xef, 0xbd, 0xae, 0x15, 0x0f, 0x09, 0x33, 0x82, 0x09, 0xbc, 0x9e, 0x15,
|
||||
0xec, 0xf7, 0xf2, 0xcb, 0x81, 0xf1, 0xe9, 0x25, 0x91, 0x5b, 0x70, 0x9b, 0x4b, 0x21, 0xe3, 0xa3,
|
||||
0x59, 0xd6, 0xb9, 0xd0, 0x9f, 0xfe, 0xec, 0x28, 0xd3, 0xbe, 0xa8, 0x7b, 0xf8, 0x53, 0x79, 0x47,
|
||||
0x2e, 0x8f, 0x4b, 0x7f, 0x6d, 0xc3, 0xf7, 0xcf, 0x49, 0x65, 0x87, 0xed, 0xc0, 0x1e, 0xec, 0xcd,
|
||||
0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x20, 0xf8, 0x53, 0xe3, 0x02, 0x00, 0x00,
|
||||
// 288 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0xc1, 0x4e, 0xc2, 0x40,
|
||||
0x10, 0x4d, 0x01, 0xd1, 0x8e, 0x44, 0xc8, 0xc4, 0x90, 0xda, 0x60, 0x42, 0x7a, 0xe2, 0xd4, 0x03,
|
||||
0x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 0x20,
|
||||
0xab, 0x79, 0x46, 0x51, 0xdf, 0x93, 0xbf, 0x85, 0x6a, 0x85, 0x0a, 0x44, 0x03, 0x4f, 0xf8, 0xf7,
|
||||
0xf2, 0x3b, 0x80, 0xc9, 0x71, 0xb6, 0x78, 0x0f, 0xe1, 0x4a, 0xeb, 0xbd, 0x20, 0xfb, 0xaa, 0x70,
|
||||
0xd2, 0xd9, 0x65, 0x5d, 0x68, 0xf7, 0x15, 0xcf, 0x3a, 0x95, 0xb6, 0xaf, 0x0d, 0xea, 0x11, 0xce,
|
||||
0x9b, 0xec, 0xf0, 0xa6, 0x2b, 0xfd, 0x73, 0x8d, 0x38, 0x3e, 0x45, 0xd5, 0x13, 0xb6, 0x43, 0x7f,
|
||||
0xc2, 0xbb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0x09, 0x4d, 0x36, 0xf5, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: RestoreItemAction.proto
|
||||
|
||||
package generated
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type RestoreExecuteRequest struct {
|
||||
Item []byte `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
|
||||
Restore []byte `protobuf:"bytes,2,opt,name=restore,proto3" json:"restore,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RestoreExecuteRequest) Reset() { *m = RestoreExecuteRequest{} }
|
||||
func (m *RestoreExecuteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*RestoreExecuteRequest) ProtoMessage() {}
|
||||
func (*RestoreExecuteRequest) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
|
||||
|
||||
func (m *RestoreExecuteRequest) GetItem() []byte {
|
||||
if m != nil {
|
||||
return m.Item
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *RestoreExecuteRequest) GetRestore() []byte {
|
||||
if m != nil {
|
||||
return m.Restore
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RestoreExecuteResponse struct {
|
||||
Item []byte `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
|
||||
Warning string `protobuf:"bytes,2,opt,name=warning" json:"warning,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RestoreExecuteResponse) Reset() { *m = RestoreExecuteResponse{} }
|
||||
func (m *RestoreExecuteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*RestoreExecuteResponse) ProtoMessage() {}
|
||||
func (*RestoreExecuteResponse) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} }
|
||||
|
||||
func (m *RestoreExecuteResponse) GetItem() []byte {
|
||||
if m != nil {
|
||||
return m.Item
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *RestoreExecuteResponse) GetWarning() string {
|
||||
if m != nil {
|
||||
return m.Warning
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*RestoreExecuteRequest)(nil), "generated.RestoreExecuteRequest")
|
||||
proto.RegisterType((*RestoreExecuteResponse)(nil), "generated.RestoreExecuteResponse")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for RestoreItemAction service
|
||||
|
||||
type RestoreItemActionClient interface {
|
||||
AppliesTo(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*AppliesToResponse, error)
|
||||
Execute(ctx context.Context, in *RestoreExecuteRequest, opts ...grpc.CallOption) (*RestoreExecuteResponse, error)
|
||||
}
|
||||
|
||||
type restoreItemActionClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewRestoreItemActionClient(cc *grpc.ClientConn) RestoreItemActionClient {
|
||||
return &restoreItemActionClient{cc}
|
||||
}
|
||||
|
||||
func (c *restoreItemActionClient) AppliesTo(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*AppliesToResponse, error) {
|
||||
out := new(AppliesToResponse)
|
||||
err := grpc.Invoke(ctx, "/generated.RestoreItemAction/AppliesTo", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *restoreItemActionClient) Execute(ctx context.Context, in *RestoreExecuteRequest, opts ...grpc.CallOption) (*RestoreExecuteResponse, error) {
|
||||
out := new(RestoreExecuteResponse)
|
||||
err := grpc.Invoke(ctx, "/generated.RestoreItemAction/Execute", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for RestoreItemAction service
|
||||
|
||||
type RestoreItemActionServer interface {
|
||||
AppliesTo(context.Context, *Empty) (*AppliesToResponse, error)
|
||||
Execute(context.Context, *RestoreExecuteRequest) (*RestoreExecuteResponse, error)
|
||||
}
|
||||
|
||||
func RegisterRestoreItemActionServer(s *grpc.Server, srv RestoreItemActionServer) {
|
||||
s.RegisterService(&_RestoreItemAction_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _RestoreItemAction_AppliesTo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RestoreItemActionServer).AppliesTo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/generated.RestoreItemAction/AppliesTo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RestoreItemActionServer).AppliesTo(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _RestoreItemAction_Execute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RestoreExecuteRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(RestoreItemActionServer).Execute(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/generated.RestoreItemAction/Execute",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(RestoreItemActionServer).Execute(ctx, req.(*RestoreExecuteRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _RestoreItemAction_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "generated.RestoreItemAction",
|
||||
HandlerType: (*RestoreItemActionServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AppliesTo",
|
||||
Handler: _RestoreItemAction_AppliesTo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Execute",
|
||||
Handler: _RestoreItemAction_Execute_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "RestoreItemAction.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("RestoreItemAction.proto", fileDescriptor3) }
|
||||
|
||||
var fileDescriptor3 = []byte{
|
||||
// 210 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x0f, 0x4a, 0x2d, 0x2e,
|
||||
0xc9, 0x2f, 0x4a, 0xf5, 0x2c, 0x49, 0xcd, 0x75, 0x4c, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28,
|
||||
0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4c, 0x4f, 0xcd, 0x4b, 0x2d, 0x4a, 0x2c, 0x49, 0x4d, 0x91, 0xe2,
|
||||
0x09, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0x81, 0x48, 0x28, 0xb9, 0x72, 0x89, 0x42, 0xf5, 0xb8, 0x56,
|
||||
0xa4, 0x26, 0x97, 0x96, 0xa4, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1,
|
||||
0x64, 0x96, 0xa4, 0xe6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0xd9, 0x42, 0x12, 0x5c,
|
||||
0xec, 0x45, 0x10, 0xc5, 0x12, 0x4c, 0x60, 0x61, 0x18, 0x57, 0xc9, 0x8d, 0x4b, 0x0c, 0xdd, 0x98,
|
||||
0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x5c, 0xe6, 0x94, 0x27, 0x16, 0xe5, 0x65, 0xe6, 0xa5, 0x83,
|
||||
0xcd, 0xe1, 0x0c, 0x82, 0x71, 0x8d, 0x16, 0x30, 0x72, 0x09, 0x62, 0xf8, 0x41, 0xc8, 0x9a, 0x8b,
|
||||
0xd3, 0xb1, 0xa0, 0x20, 0x27, 0x33, 0xb5, 0x38, 0x24, 0x5f, 0x48, 0x40, 0x0f, 0xee, 0x17, 0x3d,
|
||||
0xd7, 0xdc, 0x82, 0x92, 0x4a, 0x29, 0x19, 0x24, 0x11, 0xb8, 0x3a, 0xb8, 0x03, 0xfc, 0xb8, 0xd8,
|
||||
0xa1, 0x6e, 0x12, 0x52, 0x40, 0x52, 0x88, 0xd5, 0xd7, 0x52, 0x8a, 0x78, 0x54, 0x40, 0xcc, 0x4b,
|
||||
0x62, 0x03, 0x07, 0x9c, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x08, 0x09, 0x74, 0x6c, 0x01,
|
||||
0x00, 0x00,
|
||||
}
|
||||
@@ -18,7 +18,7 @@ type Empty struct {
|
||||
func (m *Empty) Reset() { *m = Empty{} }
|
||||
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
||||
func (*Empty) ProtoMessage() {}
|
||||
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
|
||||
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} }
|
||||
|
||||
type InitRequest struct {
|
||||
Config map[string]string `protobuf:"bytes,1,rep,name=config" json:"config,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
@@ -27,7 +27,7 @@ type InitRequest struct {
|
||||
func (m *InitRequest) Reset() { *m = InitRequest{} }
|
||||
func (m *InitRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*InitRequest) ProtoMessage() {}
|
||||
func (*InitRequest) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} }
|
||||
func (*InitRequest) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{1} }
|
||||
|
||||
func (m *InitRequest) GetConfig() map[string]string {
|
||||
if m != nil {
|
||||
@@ -36,23 +36,79 @@ func (m *InitRequest) GetConfig() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
type AppliesToResponse struct {
|
||||
IncludedNamespaces []string `protobuf:"bytes,1,rep,name=includedNamespaces" json:"includedNamespaces,omitempty"`
|
||||
ExcludedNamespaces []string `protobuf:"bytes,2,rep,name=excludedNamespaces" json:"excludedNamespaces,omitempty"`
|
||||
IncludedResources []string `protobuf:"bytes,3,rep,name=includedResources" json:"includedResources,omitempty"`
|
||||
ExcludedResources []string `protobuf:"bytes,4,rep,name=excludedResources" json:"excludedResources,omitempty"`
|
||||
Selector string `protobuf:"bytes,5,opt,name=selector" json:"selector,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) Reset() { *m = AppliesToResponse{} }
|
||||
func (m *AppliesToResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*AppliesToResponse) ProtoMessage() {}
|
||||
func (*AppliesToResponse) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{2} }
|
||||
|
||||
func (m *AppliesToResponse) GetIncludedNamespaces() []string {
|
||||
if m != nil {
|
||||
return m.IncludedNamespaces
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetExcludedNamespaces() []string {
|
||||
if m != nil {
|
||||
return m.ExcludedNamespaces
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetIncludedResources() []string {
|
||||
if m != nil {
|
||||
return m.IncludedResources
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetExcludedResources() []string {
|
||||
if m != nil {
|
||||
return m.ExcludedResources
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AppliesToResponse) GetSelector() string {
|
||||
if m != nil {
|
||||
return m.Selector
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Empty)(nil), "generated.Empty")
|
||||
proto.RegisterType((*InitRequest)(nil), "generated.InitRequest")
|
||||
proto.RegisterType((*AppliesToResponse)(nil), "generated.AppliesToResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("Shared.proto", fileDescriptor3) }
|
||||
func init() { proto.RegisterFile("Shared.proto", fileDescriptor4) }
|
||||
|
||||
var fileDescriptor3 = []byte{
|
||||
// 156 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x09, 0xce, 0x48, 0x2c,
|
||||
0x4a, 0x4d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4c, 0x4f, 0xcd, 0x4b, 0x2d, 0x4a,
|
||||
0x2c, 0x49, 0x4d, 0x51, 0x62, 0xe7, 0x62, 0x75, 0xcd, 0x2d, 0x28, 0xa9, 0x54, 0x6a, 0x61, 0xe4,
|
||||
0xe2, 0xf6, 0xcc, 0xcb, 0x2c, 0x09, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0xb2, 0xe2, 0x62,
|
||||
0x4b, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0x97, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd2, 0x83,
|
||||
0x6b, 0xd2, 0x43, 0x52, 0xa7, 0xe7, 0x0c, 0x56, 0xe4, 0x9a, 0x57, 0x52, 0x54, 0x19, 0x04, 0xd5,
|
||||
0x21, 0x65, 0xc9, 0xc5, 0x8d, 0x24, 0x2c, 0x24, 0xc0, 0xc5, 0x9c, 0x9d, 0x5a, 0x29, 0xc1, 0xa8,
|
||||
0xc0, 0xa8, 0xc1, 0x19, 0x04, 0x62, 0x0a, 0x89, 0x70, 0xb1, 0x96, 0x25, 0xe6, 0x94, 0xa6, 0x4a,
|
||||
0x30, 0x81, 0xc5, 0x20, 0x1c, 0x2b, 0x26, 0x0b, 0xc6, 0x24, 0x36, 0xb0, 0x0b, 0x8d, 0x01, 0x01,
|
||||
0x00, 0x00, 0xff, 0xff, 0x85, 0xab, 0x54, 0x37, 0xb1, 0x00, 0x00, 0x00,
|
||||
var fileDescriptor4 = []byte{
|
||||
// 257 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xd1, 0xb1, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x06, 0x60, 0xb9, 0x21, 0x85, 0x5c, 0x18, 0xa8, 0xc5, 0x10, 0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 0x27, 0xfc, 0x82, 0x66, 0xbb, 0x2d,
|
||||
0x02, 0x4e, 0xb7, 0xb6, 0xe7, 0x51, 0xe0, 0xe3, 0xa0, 0xd7, 0xbb, 0x1d, 0x7f, 0xfa, 0x68, 0xd0,
|
||||
0xa3, 0x80, 0xcf, 0xe9, 0xc4, 0xa1, 0x41, 0xe9, 0xb5, 0xcd, 0xe2, 0xf0, 0xdc, 0x7d, 0xfd, 0x3c,
|
||||
0x0d, 0xff, 0x71, 0xf5, 0x13, 0x00, 0x00, 0xff, 0xff, 0x19, 0xd7, 0x88, 0x92, 0x9f, 0x01, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
+85
-13
@@ -23,13 +23,13 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/heptio/ark/pkg/backup"
|
||||
"github.com/heptio/ark/pkg/cloudprovider"
|
||||
"github.com/heptio/ark/pkg/restore"
|
||||
)
|
||||
|
||||
// PluginKind is a type alias for a string that describes
|
||||
@@ -71,6 +71,10 @@ const (
|
||||
// a Backup ItemAction plugin.
|
||||
PluginKindBackupItemAction PluginKind = "backupitemaction"
|
||||
|
||||
// PluginKindRestoreItemAction is the Kind string for
|
||||
// a Restore ItemAction plugin.
|
||||
PluginKindRestoreItemAction PluginKind = "restoreitemaction"
|
||||
|
||||
pluginDir = "/plugins"
|
||||
)
|
||||
|
||||
@@ -79,6 +83,7 @@ var AllPluginKinds = []PluginKind{
|
||||
PluginKindBlockStore,
|
||||
PluginKindCloudProvider,
|
||||
PluginKindBackupItemAction,
|
||||
PluginKindRestoreItemAction,
|
||||
}
|
||||
|
||||
type pluginInfo struct {
|
||||
@@ -104,15 +109,26 @@ type Manager interface {
|
||||
// (mainly because each one outputs to a per-backup log),
|
||||
// and should be terminated upon completion of the backup with
|
||||
// CloseBackupItemActions().
|
||||
GetBackupItemActions(backupName string, logger logrus.FieldLogger, level logrus.Level) ([]backup.ItemAction, error)
|
||||
GetBackupItemActions(backupName string) ([]backup.ItemAction, error)
|
||||
|
||||
// CloseBackupItemActions terminates the plugin sub-processes that
|
||||
// are hosting BackupItemAction plugins for the given backup name.
|
||||
CloseBackupItemActions(backupName string) error
|
||||
|
||||
// GetRestoreItemActions returns all restore.ItemAction plugins.
|
||||
// These plugin instances should ONLY be used for a single restore
|
||||
// (mainly because each one outputs to a per-restore log),
|
||||
// and should be terminated upon completion of the restore with
|
||||
// CloseRestoreItemActions().
|
||||
GetRestoreItemActions(restoreName string) ([]restore.ItemAction, error)
|
||||
|
||||
// CloseRestoreItemActions terminates the plugin sub-processes that
|
||||
// are hosting RestoreItemAction plugins for the given restore name.
|
||||
CloseRestoreItemActions(restoreName string) error
|
||||
}
|
||||
|
||||
type manager struct {
|
||||
logger hclog.Logger
|
||||
logger *logrusAdapter
|
||||
pluginRegistry *registry
|
||||
clientStore *clientStore
|
||||
}
|
||||
@@ -162,7 +178,11 @@ func (m *manager) registerPlugins() error {
|
||||
for _, provider := range []string{"aws", "gcp", "azure"} {
|
||||
m.pluginRegistry.register(provider, "/ark", []string{"plugin", "cloudprovider", provider}, PluginKindObjectStore, PluginKindBlockStore)
|
||||
}
|
||||
m.pluginRegistry.register("backup_pv", "/ark", []string{"plugin", string(PluginKindBackupItemAction), "backup_pv"}, PluginKindBackupItemAction)
|
||||
m.pluginRegistry.register("pv", "/ark", []string{"plugin", string(PluginKindBackupItemAction), "pv"}, PluginKindBackupItemAction)
|
||||
|
||||
m.pluginRegistry.register("job", "/ark", []string{"plugin", string(PluginKindRestoreItemAction), "job"}, PluginKindRestoreItemAction)
|
||||
m.pluginRegistry.register("pod", "/ark", []string{"plugin", string(PluginKindRestoreItemAction), "pod"}, PluginKindRestoreItemAction)
|
||||
m.pluginRegistry.register("svc", "/ark", []string{"plugin", string(PluginKindRestoreItemAction), "svc"}, PluginKindRestoreItemAction)
|
||||
|
||||
// second, register external plugins (these will override internal plugins, if applicable)
|
||||
if _, err := os.Stat(pluginDir); err != nil {
|
||||
@@ -272,7 +292,7 @@ func (m *manager) getCloudProviderPlugin(name string, kind PluginKind) (interfac
|
||||
// (mainly because each one outputs to a per-backup log),
|
||||
// and should be terminated upon completion of the backup with
|
||||
// CloseBackupActions().
|
||||
func (m *manager) GetBackupItemActions(backupName string, logger logrus.FieldLogger, level logrus.Level) ([]backup.ItemAction, error) {
|
||||
func (m *manager) GetBackupItemActions(backupName string) ([]backup.ItemAction, error) {
|
||||
clients, err := m.clientStore.list(PluginKindBackupItemAction, backupName)
|
||||
if err != nil {
|
||||
pluginInfo, err := m.pluginRegistry.list(PluginKindBackupItemAction)
|
||||
@@ -280,14 +300,12 @@ func (m *manager) GetBackupItemActions(backupName string, logger logrus.FieldLog
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create clients for each, using the provided logger
|
||||
log := &logrusAdapter{impl: logger, level: level}
|
||||
|
||||
// create clients for each
|
||||
for _, plugin := range pluginInfo {
|
||||
client := newClientBuilder(baseConfig()).
|
||||
withCommand(plugin.commandName, plugin.commandArgs...).
|
||||
withPlugin(PluginKindBackupItemAction, &BackupItemActionPlugin{log: log}).
|
||||
withLogger(log).
|
||||
withPlugin(PluginKindBackupItemAction, &BackupItemActionPlugin{log: m.logger}).
|
||||
withLogger(m.logger).
|
||||
client()
|
||||
|
||||
m.clientStore.add(client, PluginKindBackupItemAction, plugin.name, backupName)
|
||||
@@ -300,12 +318,14 @@ func (m *manager) GetBackupItemActions(backupName string, logger logrus.FieldLog
|
||||
for _, client := range clients {
|
||||
plugin, err := getPluginInstance(client, PluginKindBackupItemAction)
|
||||
if err != nil {
|
||||
m.CloseBackupItemActions(backupName)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
backupAction, ok := plugin.(backup.ItemAction)
|
||||
if !ok {
|
||||
return nil, errors.New("could not convert gRPC client to backup.BackupAction")
|
||||
m.CloseBackupItemActions(backupName)
|
||||
return nil, errors.New("could not convert gRPC client to backup.ItemAction")
|
||||
}
|
||||
|
||||
backupActions = append(backupActions, backupAction)
|
||||
@@ -317,7 +337,59 @@ func (m *manager) GetBackupItemActions(backupName string, logger logrus.FieldLog
|
||||
// CloseBackupItemActions terminates the plugin sub-processes that
|
||||
// are hosting BackupItemAction plugins for the given backup name.
|
||||
func (m *manager) CloseBackupItemActions(backupName string) error {
|
||||
clients, err := m.clientStore.list(PluginKindBackupItemAction, backupName)
|
||||
return closeAll(m.clientStore, PluginKindBackupItemAction, backupName)
|
||||
}
|
||||
|
||||
func (m *manager) GetRestoreItemActions(restoreName string) ([]restore.ItemAction, error) {
|
||||
clients, err := m.clientStore.list(PluginKindRestoreItemAction, restoreName)
|
||||
if err != nil {
|
||||
pluginInfo, err := m.pluginRegistry.list(PluginKindRestoreItemAction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create clients for each
|
||||
for _, plugin := range pluginInfo {
|
||||
client := newClientBuilder(baseConfig()).
|
||||
withCommand(plugin.commandName, plugin.commandArgs...).
|
||||
withPlugin(PluginKindRestoreItemAction, &RestoreItemActionPlugin{log: m.logger}).
|
||||
withLogger(m.logger).
|
||||
client()
|
||||
|
||||
m.clientStore.add(client, PluginKindRestoreItemAction, plugin.name, restoreName)
|
||||
|
||||
clients = append(clients, client)
|
||||
}
|
||||
}
|
||||
|
||||
var itemActions []restore.ItemAction
|
||||
for _, client := range clients {
|
||||
plugin, err := getPluginInstance(client, PluginKindRestoreItemAction)
|
||||
if err != nil {
|
||||
m.CloseRestoreItemActions(restoreName)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
itemAction, ok := plugin.(restore.ItemAction)
|
||||
if !ok {
|
||||
m.CloseRestoreItemActions(restoreName)
|
||||
return nil, errors.New("could not convert gRPC client to restore.ItemAction")
|
||||
}
|
||||
|
||||
itemActions = append(itemActions, itemAction)
|
||||
}
|
||||
|
||||
return itemActions, nil
|
||||
}
|
||||
|
||||
// CloseRestoreItemActions terminates the plugin sub-processes that
|
||||
// are hosting RestoreItemAction plugins for the given restore name.
|
||||
func (m *manager) CloseRestoreItemActions(restoreName string) error {
|
||||
return closeAll(m.clientStore, PluginKindRestoreItemAction, restoreName)
|
||||
}
|
||||
|
||||
func closeAll(store *clientStore, kind PluginKind, scope string) error {
|
||||
clients, err := store.list(kind, scope)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -326,7 +398,7 @@ func (m *manager) CloseBackupItemActions(backupName string) error {
|
||||
client.Kill()
|
||||
}
|
||||
|
||||
m.clientStore.deleteAll(PluginKindBackupItemAction, backupName)
|
||||
store.deleteAll(kind, scope)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,14 +3,6 @@ package generated;
|
||||
|
||||
import "Shared.proto";
|
||||
|
||||
message AppliesToResponse {
|
||||
repeated string includedNamespaces = 1;
|
||||
repeated string excludedNamespaces = 2;
|
||||
repeated string includedResources = 3;
|
||||
repeated string excludedResources = 4;
|
||||
string selector = 5;
|
||||
}
|
||||
|
||||
message ExecuteRequest {
|
||||
bytes item = 1;
|
||||
bytes backup = 2;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
package generated;
|
||||
|
||||
import "Shared.proto";
|
||||
|
||||
message RestoreExecuteRequest {
|
||||
bytes item = 1;
|
||||
bytes restore = 2;
|
||||
}
|
||||
|
||||
message RestoreExecuteResponse {
|
||||
bytes item = 1;
|
||||
string warning = 2;
|
||||
}
|
||||
|
||||
service RestoreItemAction {
|
||||
rpc AppliesTo(Empty) returns (AppliesToResponse);
|
||||
rpc Execute(RestoreExecuteRequest) returns (RestoreExecuteResponse);
|
||||
}
|
||||
@@ -5,4 +5,12 @@ message Empty {}
|
||||
|
||||
message InitRequest {
|
||||
map<string, string> config = 1;
|
||||
}
|
||||
|
||||
message AppliesToResponse {
|
||||
repeated string includedNamespaces = 1;
|
||||
repeated string excludedNamespaces = 2;
|
||||
repeated string includedResources = 3;
|
||||
repeated string excludedResources = 4;
|
||||
string selector = 5;
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
Copyright 2017 the Heptio Ark 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 plugin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
proto "github.com/heptio/ark/pkg/plugin/generated"
|
||||
"github.com/heptio/ark/pkg/restore"
|
||||
)
|
||||
|
||||
// RestoreItemActionPlugin is an implementation of go-plugin's Plugin
|
||||
// interface with support for gRPC for the restore/ItemAction
|
||||
// interface.
|
||||
type RestoreItemActionPlugin struct {
|
||||
plugin.NetRPCUnsupportedPlugin
|
||||
impl restore.ItemAction
|
||||
log *logrusAdapter
|
||||
}
|
||||
|
||||
// NewRestoreItemActionPlugin constructs a RestoreItemActionPlugin.
|
||||
func NewRestoreItemActionPlugin(itemAction restore.ItemAction) *RestoreItemActionPlugin {
|
||||
return &RestoreItemActionPlugin{
|
||||
impl: itemAction,
|
||||
}
|
||||
}
|
||||
|
||||
// GRPCServer registers a RestoreItemAction gRPC server.
|
||||
func (p *RestoreItemActionPlugin) GRPCServer(s *grpc.Server) error {
|
||||
proto.RegisterRestoreItemActionServer(s, &RestoreItemActionGRPCServer{impl: p.impl})
|
||||
return nil
|
||||
}
|
||||
|
||||
// GRPCClient returns a RestoreItemAction gRPC client.
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
|
||||
return &RestoreItemActionGRPCClient{grpcClient: proto.NewRestoreItemActionClient(c), log: p.log}, nil
|
||||
}
|
||||
|
||||
// RestoreItemActionGRPCClient implements the backup/ItemAction interface and uses a
|
||||
// gRPC client to make calls to the plugin server.
|
||||
type RestoreItemActionGRPCClient struct {
|
||||
grpcClient proto.RestoreItemActionClient
|
||||
log *logrusAdapter
|
||||
}
|
||||
|
||||
func (c *RestoreItemActionGRPCClient) AppliesTo() (restore.ResourceSelector, error) {
|
||||
res, err := c.grpcClient.AppliesTo(context.Background(), &proto.Empty{})
|
||||
if err != nil {
|
||||
return restore.ResourceSelector{}, err
|
||||
}
|
||||
|
||||
return restore.ResourceSelector{
|
||||
IncludedNamespaces: res.IncludedNamespaces,
|
||||
ExcludedNamespaces: res.ExcludedNamespaces,
|
||||
IncludedResources: res.IncludedResources,
|
||||
ExcludedResources: res.ExcludedResources,
|
||||
LabelSelector: res.Selector,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *RestoreItemActionGRPCClient) Execute(item runtime.Unstructured, restore *api.Restore) (runtime.Unstructured, error, error) {
|
||||
itemJSON, err := json.Marshal(item.UnstructuredContent())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
restoreJSON, err := json.Marshal(restore)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req := &proto.RestoreExecuteRequest{
|
||||
Item: itemJSON,
|
||||
Restore: restoreJSON,
|
||||
}
|
||||
|
||||
res, err := c.grpcClient.Execute(context.Background(), req)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var updatedItem unstructured.Unstructured
|
||||
if err := json.Unmarshal(res.Item, &updatedItem); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var warning error
|
||||
if res.Warning != "" {
|
||||
warning = errors.New(res.Warning)
|
||||
}
|
||||
|
||||
return &updatedItem, warning, nil
|
||||
}
|
||||
|
||||
func (c *RestoreItemActionGRPCClient) SetLog(log logrus.FieldLogger) {
|
||||
c.log.impl = log
|
||||
}
|
||||
|
||||
// RestoreItemActionGRPCServer implements the proto-generated RestoreItemActionServer interface, and accepts
|
||||
// gRPC calls and forwards them to an implementation of the pluggable interface.
|
||||
type RestoreItemActionGRPCServer struct {
|
||||
impl restore.ItemAction
|
||||
}
|
||||
|
||||
func (s *RestoreItemActionGRPCServer) AppliesTo(ctx context.Context, req *proto.Empty) (*proto.AppliesToResponse, error) {
|
||||
appliesTo, err := s.impl.AppliesTo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &proto.AppliesToResponse{
|
||||
IncludedNamespaces: appliesTo.IncludedNamespaces,
|
||||
ExcludedNamespaces: appliesTo.ExcludedNamespaces,
|
||||
IncludedResources: appliesTo.IncludedResources,
|
||||
ExcludedResources: appliesTo.ExcludedResources,
|
||||
Selector: appliesTo.LabelSelector,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *RestoreItemActionGRPCServer) Execute(ctx context.Context, req *proto.RestoreExecuteRequest) (*proto.RestoreExecuteResponse, error) {
|
||||
var (
|
||||
item unstructured.Unstructured
|
||||
restore api.Restore
|
||||
)
|
||||
|
||||
if err := json.Unmarshal(req.Item, &item); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(req.Restore, &restore); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, warning, err := s.impl.Execute(&item, &restore)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updatedItem, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var warnMessage string
|
||||
if warning != nil {
|
||||
warnMessage = warning.Error()
|
||||
}
|
||||
|
||||
return &proto.RestoreExecuteResponse{
|
||||
Item: updatedItem,
|
||||
Warning: warnMessage,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user