Merge pull request #1074 from mwieczorek/del-priority

Delete spec.priority in pod restore action
This commit is contained in:
Andy Goldstein
2018-11-26 14:05:51 -05:00
committed by GitHub
3 changed files with 16 additions and 2 deletions
+3
View File
@@ -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
+10 -2
View File
@@ -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,
},
+3
View File
@@ -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...)
}