RestoreItemAction v1 refactoring for plugin api versioning

Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
Scott Seago
2022-09-20 17:43:56 -04:00
parent 07da9b9cf8
commit 32ef20d317
51 changed files with 493 additions and 580 deletions
+4 -3
View File
@@ -26,6 +26,7 @@ import (
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
biav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/backupitemaction/v1"
isv1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/item_snapshotter/v1"
riav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/restoreitemaction/v1"
"github.com/vmware-tanzu/velero/pkg/util/collections"
)
@@ -108,7 +109,7 @@ func NewBackupItemActionResolver(actions []biav1.BackupItemAction) BackupItemAct
}
}
func NewRestoreItemActionResolver(actions []velero.RestoreItemAction) RestoreItemActionResolver {
func NewRestoreItemActionResolver(actions []riav1.RestoreItemAction) RestoreItemActionResolver {
return RestoreItemActionResolver{
actions: actions,
}
@@ -155,12 +156,12 @@ func (recv BackupItemActionResolver) ResolveActions(helper discovery.Helper, log
}
type RestoreItemResolvedAction struct {
velero.RestoreItemAction
riav1.RestoreItemAction
resolvedAction
}
type RestoreItemActionResolver struct {
actions []velero.RestoreItemAction
actions []riav1.RestoreItemAction
}
func (recv RestoreItemActionResolver) ResolveActions(helper discovery.Helper, log logrus.FieldLogger) ([]RestoreItemResolvedAction, error) {
@@ -28,9 +28,10 @@ import (
"github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
proto "github.com/vmware-tanzu/velero/pkg/plugin/generated"
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
riav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/restoreitemaction/v1"
)
var _ velero.RestoreItemAction = &RestoreItemActionGRPCClient{}
var _ riav1.RestoreItemAction = &RestoreItemActionGRPCClient{}
// NewRestoreItemActionPlugin constructs a RestoreItemActionPlugin.
func NewRestoreItemActionPlugin(options ...common.PluginOption) *RestoreItemActionPlugin {
@@ -72,7 +73,7 @@ func (c *RestoreItemActionGRPCClient) AppliesTo() (velero.ResourceSelector, erro
}, nil
}
func (c *RestoreItemActionGRPCClient) Execute(input *velero.RestoreItemActionExecuteInput) (*velero.RestoreItemActionExecuteOutput, error) {
func (c *RestoreItemActionGRPCClient) Execute(input *riav1.RestoreItemActionExecuteInput) (*riav1.RestoreItemActionExecuteOutput, error) {
itemJSON, err := json.Marshal(input.Item.UnstructuredContent())
if err != nil {
return nil, errors.WithStack(err)
@@ -119,7 +120,7 @@ func (c *RestoreItemActionGRPCClient) Execute(input *velero.RestoreItemActionExe
additionalItems = append(additionalItems, newItem)
}
return &velero.RestoreItemActionExecuteOutput{
return &riav1.RestoreItemActionExecuteOutput{
UpdatedItem: &updatedItem,
AdditionalItems: additionalItems,
SkipRestore: res.SkipRestore,
@@ -27,6 +27,7 @@ import (
"github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
proto "github.com/vmware-tanzu/velero/pkg/plugin/generated"
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
riav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/restoreitemaction/v1"
)
// RestoreItemActionGRPCServer implements the proto-generated RestoreItemActionServer interface, and accepts
@@ -35,13 +36,13 @@ type RestoreItemActionGRPCServer struct {
mux *common.ServerMux
}
func (s *RestoreItemActionGRPCServer) getImpl(name string) (velero.RestoreItemAction, error) {
func (s *RestoreItemActionGRPCServer) getImpl(name string) (riav1.RestoreItemAction, error) {
impl, err := s.mux.GetHandler(name)
if err != nil {
return nil, err
}
itemAction, ok := impl.(velero.RestoreItemAction)
itemAction, ok := impl.(riav1.RestoreItemAction)
if !ok {
return nil, errors.Errorf("%T is not a restore item action", impl)
}
@@ -107,7 +108,7 @@ func (s *RestoreItemActionGRPCServer) Execute(ctx context.Context, req *proto.Re
return nil, common.NewGRPCError(errors.WithStack(err))
}
executeOutput, err := impl.Execute(&velero.RestoreItemActionExecuteInput{
executeOutput, err := impl.Execute(&riav1.RestoreItemActionExecuteInput{
Item: &item,
ItemFromBackup: &itemFromBackup,
Restore: &restoreObj,