Skip to content

Commit

Permalink
PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Portner committed Jan 10, 2022
1 parent ccb52b2 commit 662b306
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 600 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ describe('#importSavedObjectsFromStream', () => {
});

await importSavedObjectsFromStream(options);
expect(mockValidateReferences).toHaveBeenCalledWith(
collectedObjects,
expect(mockValidateReferences).toHaveBeenCalledWith({
objects: collectedObjects,
savedObjectsClient,
namespace,
new Map([
importStateMap: new Map([
// This importStateMap is a combination of the other two
[`${collectedObjects[0].type}:${collectedObjects[0].id}`, {}],
[`foo:bar`, { isOnlyReference: true, id: 'baz' }],
])
);
]),
});
});

test('executes import hooks', async () => {
Expand Down
9 changes: 4 additions & 5 deletions src/core/server/saved_objects/import/import_saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,19 @@ export async function importSavedObjectsFromStream({
importStateMap = new Map([...importStateMap, ...checkReferenceOriginsResult.importStateMap]);

// Validate references
const validateReferencesResult = await validateReferences(
collectSavedObjectsResult.collectedObjects,
const validateReferencesResult = await validateReferences({
objects: collectSavedObjectsResult.collectedObjects,
savedObjectsClient,
namespace,
importStateMap
);
importStateMap,
});
errorAccumulator = [...errorAccumulator, ...validateReferencesResult];

if (createNewCopies) {
importStateMap = new Map([
...importStateMap, // preserve any entries for references that aren't included in collectedObjects
...regenerateIds(collectSavedObjectsResult.collectedObjects),
]);
// TODO: check reference origins!
} else {
// Check single-namespace objects for conflicts in this namespace, and check multi-namespace objects for conflicts across all namespaces
const checkConflictsParams = {
Expand Down
Loading

0 comments on commit 662b306

Please sign in to comment.