diff --git a/cli/internal/helm/backup.go b/cli/internal/helm/backup.go index ad371d74d..ad081d678 100644 --- a/cli/internal/helm/backup.go +++ b/cli/internal/helm/backup.go @@ -63,7 +63,7 @@ func (c *Client) backupCRs(ctx context.Context, crds []apiextensionsv1.CustomRes } for _, cr := range crs { - targetFolder := filepath.Join(backupFolder, cr.GetKind(), cr.GetNamespace()) + targetFolder := filepath.Join(backupFolder, gvr.Group, gvr.Version, cr.GetNamespace(), cr.GetKind()) if err := c.fs.MkdirAll(targetFolder); err != nil { return fmt.Errorf("creating resource dir: %w", err) } diff --git a/cli/internal/helm/backup_test.go b/cli/internal/helm/backup_test.go index abc2ed06e..5ae71e929 100644 --- a/cli/internal/helm/backup_test.go +++ b/cli/internal/helm/backup_test.go @@ -133,7 +133,7 @@ func TestBackupCRs(t *testing.T) { } assert.NoError(err) - data, err := afero.ReadFile(memFs, filepath.Join(backupFolder, tc.resource.GetKind(), tc.resource.GetNamespace(), tc.resource.GetName()+".yaml")) + data, err := afero.ReadFile(memFs, filepath.Join(backupFolder, tc.crd.Spec.Group, tc.crd.Spec.Versions[0].Name, tc.resource.GetNamespace(), tc.resource.GetKind(), tc.resource.GetName()+".yaml")) require.NoError(err) assert.YAMLEq(tc.expectedFile, string(data)) })