Merge pull request #7195 from reasonerjt/fix-7190

Use a new variable for resource path
This commit is contained in:
Wenkai Yin(尹文开)
2023-12-11 10:47:19 +08:00
committed by GitHub
+3 -2
View File
@@ -2277,6 +2277,7 @@ func (ctx *restoreContext) getSelectedRestoreableItems(resource string, namespac
ctx.log.Infof("Resource '%s' will be restored at cluster scope", resource)
}
resourceForPath := resource
// If the APIGroupVersionsFeatureFlag is enabled, the item path will be
// updated to include the API group version that was chosen for restore. For
// example, for "horizontalpodautoscalers.autoscaling", if v2beta1 is chosen
@@ -2288,11 +2289,11 @@ func (ctx *restoreContext) getSelectedRestoreableItems(resource string, namespac
// required backup format version has been met.
cgv, ok := ctx.chosenGrpVersToRestore[resource]
if ok {
resource = filepath.Join(resource, cgv.Dir)
resourceForPath = filepath.Join(resource, cgv.Dir)
}
for _, item := range items {
itemPath := archive.GetItemFilePath(ctx.restoreDir, resource, originalNamespace, item)
itemPath := archive.GetItemFilePath(ctx.restoreDir, resourceForPath, originalNamespace, item)
obj, err := archive.Unmarshal(ctx.fileSystem, itemPath)
if err != nil {