mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-02 22:27:06 +00:00
moved RIA execute input/output structs back to velero package
The RIA refactoring moved velero.RestoreItemAction into a separate (restoreitemaction) v1 package. Unfortunately, this change would require plugins to make code changes to locate the RestoreItemActionExecuteInput and RestoreItemActionExecuteOutput structs. This commit restores those structs to the original velero package, leaving just the RestoreItemAction interface in the new v1 package. Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
@@ -99,7 +99,7 @@ func (r RestartableRestoreItemAction) AppliesTo() (velero.ResourceSelector, erro
|
||||
}
|
||||
|
||||
// Execute restarts the plugin's process if needed, then delegates the call.
|
||||
func (r *RestartableRestoreItemAction) Execute(input *riav1.RestoreItemActionExecuteInput) (*riav1.RestoreItemActionExecuteOutput, error) {
|
||||
func (r *RestartableRestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInput) (*velero.RestoreItemActionExecuteOutput, error) {
|
||||
delegate, err := r.getDelegate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/framework/common"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
|
||||
mocks "github.com/vmware-tanzu/velero/pkg/plugin/velero/mocks/restoreitemaction/v1"
|
||||
riav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/restoreitemaction/v1"
|
||||
)
|
||||
|
||||
func TestRestartableGetRestoreItemAction(t *testing.T) {
|
||||
@@ -108,13 +107,13 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
input := &riav1.RestoreItemActionExecuteInput{
|
||||
input := &velero.RestoreItemActionExecuteInput{
|
||||
Item: pv,
|
||||
ItemFromBackup: pv,
|
||||
Restore: new(v1.Restore),
|
||||
}
|
||||
|
||||
output := &riav1.RestoreItemActionExecuteOutput{
|
||||
output := &velero.RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"color": "green",
|
||||
|
||||
@@ -73,7 +73,7 @@ func (c *RestoreItemActionGRPCClient) AppliesTo() (velero.ResourceSelector, erro
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *RestoreItemActionGRPCClient) Execute(input *riav1.RestoreItemActionExecuteInput) (*riav1.RestoreItemActionExecuteOutput, error) {
|
||||
func (c *RestoreItemActionGRPCClient) Execute(input *velero.RestoreItemActionExecuteInput) (*velero.RestoreItemActionExecuteOutput, error) {
|
||||
itemJSON, err := json.Marshal(input.Item.UnstructuredContent())
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
@@ -120,7 +120,7 @@ func (c *RestoreItemActionGRPCClient) Execute(input *riav1.RestoreItemActionExec
|
||||
additionalItems = append(additionalItems, newItem)
|
||||
}
|
||||
|
||||
return &riav1.RestoreItemActionExecuteOutput{
|
||||
return &velero.RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: &updatedItem,
|
||||
AdditionalItems: additionalItems,
|
||||
SkipRestore: res.SkipRestore,
|
||||
|
||||
@@ -108,7 +108,7 @@ func (s *RestoreItemActionGRPCServer) Execute(ctx context.Context, req *proto.Re
|
||||
return nil, common.NewGRPCError(errors.WithStack(err))
|
||||
}
|
||||
|
||||
executeOutput, err := impl.Execute(&riav1.RestoreItemActionExecuteInput{
|
||||
executeOutput, err := impl.Execute(&velero.RestoreItemActionExecuteInput{
|
||||
Item: &item,
|
||||
ItemFromBackup: &itemFromBackup,
|
||||
Restore: &restoreObj,
|
||||
|
||||
@@ -20,7 +20,6 @@ package v1
|
||||
import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
velero "github.com/vmware-tanzu/velero/pkg/plugin/velero"
|
||||
riav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/restoreitemaction/v1"
|
||||
)
|
||||
|
||||
// RestoreItemAction is an autogenerated mock type for the RestoreItemAction type
|
||||
@@ -50,20 +49,20 @@ func (_m *RestoreItemAction) AppliesTo() (velero.ResourceSelector, error) {
|
||||
}
|
||||
|
||||
// Execute provides a mock function with given fields: input
|
||||
func (_m *RestoreItemAction) Execute(input *riav1.RestoreItemActionExecuteInput) (*riav1.RestoreItemActionExecuteOutput, error) {
|
||||
func (_m *RestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInput) (*velero.RestoreItemActionExecuteOutput, error) {
|
||||
ret := _m.Called(input)
|
||||
|
||||
var r0 *riav1.RestoreItemActionExecuteOutput
|
||||
if rf, ok := ret.Get(0).(func(*riav1.RestoreItemActionExecuteInput) *riav1.RestoreItemActionExecuteOutput); ok {
|
||||
var r0 *velero.RestoreItemActionExecuteOutput
|
||||
if rf, ok := ret.Get(0).(func(*velero.RestoreItemActionExecuteInput) *velero.RestoreItemActionExecuteOutput); ok {
|
||||
r0 = rf(input)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*riav1.RestoreItemActionExecuteOutput)
|
||||
r0 = ret.Get(0).(*velero.RestoreItemActionExecuteOutput)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*riav1.RestoreItemActionExecuteInput) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(*velero.RestoreItemActionExecuteInput) error); ok {
|
||||
r1 = rf(input)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 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 velero
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
)
|
||||
|
||||
// RestoreItemActionExecuteInput contains the input parameters for the ItemAction's Execute function.
|
||||
type RestoreItemActionExecuteInput struct {
|
||||
// Item is the item being restored. It is likely different from the pristine backed up version
|
||||
// (metadata reset, changed by various restore item action plugins, etc.).
|
||||
Item runtime.Unstructured
|
||||
// ItemFromBackup is the item taken from the pristine backed up version of resource.
|
||||
ItemFromBackup runtime.Unstructured
|
||||
// Restore is the representation of the restore resource processed by Velero.
|
||||
Restore *api.Restore
|
||||
}
|
||||
|
||||
// RestoreItemActionExecuteOutput contains the output variables for the ItemAction's Execution function.
|
||||
type RestoreItemActionExecuteOutput struct {
|
||||
// UpdatedItem is the item being restored mutated by ItemAction.
|
||||
UpdatedItem runtime.Unstructured
|
||||
|
||||
// AdditionalItems is a list of additional related items that should
|
||||
// be restored.
|
||||
AdditionalItems []ResourceIdentifier
|
||||
|
||||
// SkipRestore tells velero to stop executing further actions
|
||||
// on this item, and skip the restore step. When this field's
|
||||
// value is true, AdditionalItems will be ignored.
|
||||
SkipRestore bool
|
||||
}
|
||||
|
||||
// NewRestoreItemActionExecuteOutput creates a new RestoreItemActionExecuteOutput
|
||||
func NewRestoreItemActionExecuteOutput(item runtime.Unstructured) *RestoreItemActionExecuteOutput {
|
||||
return &RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: item,
|
||||
}
|
||||
}
|
||||
|
||||
// WithoutRestore returns SkipRestore for RestoreItemActionExecuteOutput
|
||||
func (r *RestoreItemActionExecuteOutput) WithoutRestore() *RestoreItemActionExecuteOutput {
|
||||
r.SkipRestore = true
|
||||
return r
|
||||
}
|
||||
@@ -17,9 +17,6 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
|
||||
)
|
||||
|
||||
@@ -36,44 +33,5 @@ type RestoreItemAction interface {
|
||||
// related items that should be restored, a warning (which will be logged but will not prevent
|
||||
// the item from being restored) or error (which will be logged and will prevent the item
|
||||
// from being restored) if applicable.
|
||||
Execute(input *RestoreItemActionExecuteInput) (*RestoreItemActionExecuteOutput, error)
|
||||
}
|
||||
|
||||
// RestoreItemActionExecuteInput contains the input parameters for the ItemAction's Execute function.
|
||||
type RestoreItemActionExecuteInput struct {
|
||||
// Item is the item being restored. It is likely different from the pristine backed up version
|
||||
// (metadata reset, changed by various restore item action plugins, etc.).
|
||||
Item runtime.Unstructured
|
||||
// ItemFromBackup is the item taken from the pristine backed up version of resource.
|
||||
ItemFromBackup runtime.Unstructured
|
||||
// Restore is the representation of the restore resource processed by Velero.
|
||||
Restore *api.Restore
|
||||
}
|
||||
|
||||
// RestoreItemActionExecuteOutput contains the output variables for the ItemAction's Execution function.
|
||||
type RestoreItemActionExecuteOutput struct {
|
||||
// UpdatedItem is the item being restored mutated by ItemAction.
|
||||
UpdatedItem runtime.Unstructured
|
||||
|
||||
// AdditionalItems is a list of additional related items that should
|
||||
// be restored.
|
||||
AdditionalItems []velero.ResourceIdentifier
|
||||
|
||||
// SkipRestore tells velero to stop executing further actions
|
||||
// on this item, and skip the restore step. When this field's
|
||||
// value is true, AdditionalItems will be ignored.
|
||||
SkipRestore bool
|
||||
}
|
||||
|
||||
// NewRestoreItemActionExecuteOutput creates a new RestoreItemActionExecuteOutput
|
||||
func NewRestoreItemActionExecuteOutput(item runtime.Unstructured) *RestoreItemActionExecuteOutput {
|
||||
return &RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: item,
|
||||
}
|
||||
}
|
||||
|
||||
// WithoutRestore returns SkipRestore for RestoreItemActionExecuteOutput
|
||||
func (r *RestoreItemActionExecuteOutput) WithoutRestore() *RestoreItemActionExecuteOutput {
|
||||
r.SkipRestore = true
|
||||
return r
|
||||
Execute(input *velero.RestoreItemActionExecuteInput) (*velero.RestoreItemActionExecuteOutput, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user