Skip to content

Commit

Permalink
Use a new variable for resource path
Browse files Browse the repository at this point in the history
This commit avoids mistakes when checking the type of the resource
Fixes #7190

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
  • Loading branch information
reasonerjt committed Dec 10, 2023
1 parent 4070934 commit 0f49935
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Check warning on line 2292 in pkg/restore/restore.go

View check run for this annotation

Codecov / codecov/patch

pkg/restore/restore.go#L2292

Added line #L2292 was not covered by tests
}

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 {
Expand Down

0 comments on commit 0f49935

Please sign in to comment.