use old namespace in resource modifier (#6724) (#6794)

* use old namespace in resource modifier



* add changelog



* update docs



* updated after review



---------

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Co-authored-by: Guang Jiong Lou <7991675+27149chen@users.noreply.github.com>
Co-authored-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Anshul Ahuja
2023-09-12 14:54:03 +08:00
committed by GitHub
co-authored by Guang Jiong Lou Daniel Jiang
parent d9859d99ba
commit 8b8a5a2bcc
5 changed files with 12 additions and 8 deletions
+8 -8
View File
@@ -1352,6 +1352,14 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
}
}
if ctx.resourceModifiers != nil {
if errList := ctx.resourceModifiers.ApplyResourceModifierRules(obj, groupResource.String(), ctx.log); errList != nil {
for _, err := range errList {
errs.Add(namespace, err)
}
}
}
// Necessary because we may have remapped the namespace if the namespace is
// blank, don't create the key.
originalNamespace := obj.GetNamespace()
@@ -1364,14 +1372,6 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
// and which backup they came from.
addRestoreLabels(obj, ctx.restore.Name, ctx.restore.Spec.BackupName)
if ctx.resourceModifiers != nil {
if errList := ctx.resourceModifiers.ApplyResourceModifierRules(obj, groupResource.String(), ctx.log); errList != nil {
for _, err := range errList {
errs.Add(namespace, err)
}
}
}
// The object apiVersion might get modified by a RestorePlugin so we need to
// get a new client to reflect updated resource path.
newGR := schema.GroupResource{Group: obj.GroupVersionKind().Group, Resource: groupResource.Resource}