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

Fix sharing saved objects phase 2 CI #89056

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -206,6 +206,20 @@ describe('DocumentMigrator', () => {
);
});

it('coerces the current Kibana version if it has a hyphen', () => {
const validDefinition = {
kibanaVersion: '3.2.0-SNAPSHOT',
typeRegistry: createRegistry({
name: 'foo',
convertToMultiNamespaceTypeVersion: '3.2.0',
namespaceType: 'multiple',
}),
minimumConvertVersion: '0.0.0',
log: mockLogger,
};
expect(() => new DocumentMigrator(validDefinition)).not.toThrowError();
});

it('validates convertToMultiNamespaceTypeVersion is not used on a patch version', () => {
const invalidDefinition = {
kibanaVersion: '3.2.3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ export class DocumentMigrator implements VersionedTransformer {
*/
constructor({
typeRegistry,
kibanaVersion,
kibanaVersion: rawKibanaVersion,
minimumConvertVersion = DEFAULT_MINIMUM_CONVERT_VERSION,
log,
}: DocumentMigratorOptions) {
const kibanaVersion = rawKibanaVersion.split('-')[0]; // coerce a semver-like string (x.y.z-SNAPSHOT) or prerelease version (x.y.z-alpha) to a regular semver (x.y.z)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first attempted to use the Semver.coerce function, which would coerce a prerelease version such as 7.12.0-alpha to a regular semver 7.12.0. However, this only appears to work for actual prerelease tags such as -alpha, not non-standard tags such as -SNAPSHOT. So I used a simple split which will work just as well.

validateMigrationDefinition(typeRegistry, kibanaVersion, minimumConvertVersion);

this.documentMigratorOptions = { typeRegistry, kibanaVersion, log };
Expand Down