-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performs start up migration on the saved objects mapping for apm-indices
- Loading branch information
Showing
3 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/apm/server/saved_objects/migrations/update_apm_oss_index_paths.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
const apmIndexConfigPaths = [ | ||
['xpack.apm.sourcemapIndices', 'apm_oss.sourcemapIndices'], | ||
['xpack.apm.errorIndices', 'apm_oss.errorIndices'], | ||
['xpack.apm.onboardingIndices', 'apm_oss.onboardingIndices'], | ||
['xpack.apm.spanIndices', 'apm_oss.spanIndices'], | ||
['xpack.apm.transactionIndices', 'apm_oss.transactionIndices'], | ||
['xpack.apm.metricsIndices', 'apm_oss.metricsIndices'], | ||
] as const; | ||
|
||
type ApmIndexConfigsPaths = typeof apmIndexConfigPaths[number][0]; | ||
type ApmIndicesSavedObjectAttributes = Partial<{ | ||
[Property in ApmIndexConfigsPaths]: string; | ||
}>; | ||
type DeprecatedApmIndexConfigsPaths = typeof apmIndexConfigPaths[number][1]; | ||
type DeprecatedApmIndicesSavedObjectAttributes = Partial<{ | ||
[Property in DeprecatedApmIndexConfigsPaths]: string; | ||
}>; | ||
|
||
export function updateApmOssIndexPaths( | ||
attributes: DeprecatedApmIndicesSavedObjectAttributes | ||
) { | ||
return apmIndexConfigPaths.reduce( | ||
(attrs, [configPath, deprecatedConfigPath]) => { | ||
const indexConfig: string | undefined = attributes[deprecatedConfigPath]; | ||
if (indexConfig) { | ||
attrs[configPath] = indexConfig; | ||
} | ||
return attrs; | ||
}, | ||
{} as ApmIndicesSavedObjectAttributes | ||
); | ||
} |