mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 21:36:30 +00:00
Delete spec.priority in pod restore action
Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
This commit is contained in:
@@ -50,6 +50,9 @@ func (a *podAction) Execute(obj runtime.Unstructured, restore *api.Restore) (run
|
||||
a.logger.Debug("deleting spec.NodeName")
|
||||
delete(spec, "nodeName")
|
||||
|
||||
a.logger.Debug("deleting spec.priority")
|
||||
delete(spec, "priority")
|
||||
|
||||
// if there are no volumes, then there can't be any volume mounts, so we're done.
|
||||
if !collections.Exists(spec, "volumes") {
|
||||
return obj, nil, nil
|
||||
|
||||
@@ -40,12 +40,20 @@ func TestPodActionExecute(t *testing.T) {
|
||||
{
|
||||
name: "nodeName (only) should be deleted from spec",
|
||||
obj: NewTestUnstructured().WithName("pod-1").WithSpec("nodeName", "foo").
|
||||
WithSpec("serviceAccountName", "foo").
|
||||
WithSpecField("containers", []interface{}{}).
|
||||
Unstructured,
|
||||
expectedErr: false,
|
||||
expectedRes: NewTestUnstructured().WithName("pod-1").WithSpec("foo").
|
||||
WithSpec("serviceAccountName", "foo").
|
||||
WithSpecField("containers", []interface{}{}).
|
||||
Unstructured,
|
||||
},
|
||||
{
|
||||
name: "priority (only) should be deleted from spec",
|
||||
obj: NewTestUnstructured().WithName("pod-1").WithSpec("priority", "foo").
|
||||
WithSpecField("containers", []interface{}{}).
|
||||
Unstructured,
|
||||
expectedErr: false,
|
||||
expectedRes: NewTestUnstructured().WithName("pod-1").WithSpec("foo").
|
||||
WithSpecField("containers", []interface{}{}).
|
||||
Unstructured,
|
||||
},
|
||||
|
||||
@@ -1605,6 +1605,9 @@ func (obj *testUnstructured) WithMetadata(fields ...string) *testUnstructured {
|
||||
}
|
||||
|
||||
func (obj *testUnstructured) WithSpec(fields ...string) *testUnstructured {
|
||||
if _, found := obj.Object["spec"]; found {
|
||||
panic("spec already set - you probably didn't mean to do this twice!")
|
||||
}
|
||||
return obj.withMap("spec", fields...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user