Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Graph] Make Graph saved object share-capable #111404

Merged
merged 8 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,23 @@ describe('migration v2', () => {
.getTypeRegistry()
.getAllTypes()
.reduce((versionMap, type) => {
if (type.migrations) {
const migrationsMap =
typeof type.migrations === 'function' ? type.migrations() : type.migrations;
const highestVersion = Object.keys(migrationsMap).sort(Semver.compare).reverse()[0];
const { name, migrations, convertToMultiNamespaceTypeVersion } = type;
if (migrations || convertToMultiNamespaceTypeVersion) {
const migrationsMap = typeof migrations === 'function' ? migrations() : migrations;
const migrationsKeys = migrationsMap ? Object.keys(migrationsMap) : [];
if (convertToMultiNamespaceTypeVersion) {
// Setting this option registers a conversion migration that is reflected in the object's `migrationVersions` field
migrationsKeys.push(convertToMultiNamespaceTypeVersion);
}
Comment on lines +122 to +128
Copy link
Member

@kertal kertal Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: so you're checking for convertToMultiNamespaceTypeVersion 2 times. if think the first is redundant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertToMultiNamespaceTypeVersion will impact the object's migrationVersion regardless of whether a migrations object/function is defined or not.

To rephrase: the union of the object type definition's migrations and convertToMultiNamespaceTypeVersion determines the resulting objects' migrationVersion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kertal in 122 line it's || operation so all good :)

const highestVersion = migrationsKeys.sort(Semver.compare).reverse()[0];
return {
...versionMap,
[type.name]: highestVersion,
[name]: highestVersion,
};
} else {
return {
...versionMap,
[type.name]: undefined,
[name]: undefined,
};
}
}, {} as Record<string, string | undefined>);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/graph/server/saved_objects/graph_workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { graphMigrations } from './migrations';

export const graphWorkspace: SavedObjectsType = {
name: 'graph-workspace',
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jportner we don't need to adapt any call to use resolve instead of get for this specific SO type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done separately in this PR: #109617

hidden: false,
management: {
icon: 'graphApp',
Expand Down