Cleanup resetStatus

Signed-off-by: Rafael Leal <rafaelealdias@gmail.com>
This commit is contained in:
Rafael Leal
2022-05-23 17:53:32 -03:00
parent 131c8a920f
commit e0e3016efa
2 changed files with 8 additions and 19 deletions

View File

@@ -1009,7 +1009,6 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
}
if groupResource == kuberesource.PersistentVolumes {
resetStatus(obj)
switch {
case hasSnapshot(name, ctx.volumeSnapshots):
oldName := obj.GetName()
@@ -1694,21 +1693,17 @@ func resetMetadata(obj *unstructured.Unstructured) (*unstructured.Unstructured,
return obj, nil
}
func resetStatus(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
delete(obj.UnstructuredContent(), "status")
return obj, nil
func resetStatus(obj *unstructured.Unstructured) {
unstructured.RemoveNestedField(obj.UnstructuredContent(), "status")
}
func resetMetadataAndStatus(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
newObj, err := resetMetadata(obj)
_, err := resetMetadata(obj)
if err != nil {
return nil, err
}
newObj, err = resetStatus(obj)
if err != nil {
return nil, err
}
return newObj, nil
resetStatus(obj)
return obj, nil
}
// addRestoreLabels labels the provided object with the restore name and the