Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Mar 25, 2020
1 parent b19fb5e commit 7f09433
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/plugins/apm_oss/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { APMOSSPluginSetup } from './plugin';
const apmStar = 'apm-*';

const defaultConfig = {
enabled: true,
errorIndices: apmStar,
indexPattern: apmStar,
metricsIndices: apmStar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { uniq } from 'lodash';
import { uniq, pick } from 'lodash';
import { APMOSSConfig } from '../../../../../../src/plugins/apm_oss/server';

export const extractIndexPatterns = (apmConfig: Record<string, string>): string[] =>
uniq(
[
'sourcemapIndices',
'errorIndices',
'transactionIndices',
'spanIndices',
'metricsIndices',
'onboardingIndices',
].map(type => apmConfig[type]!)
);
type APMIndexConfig = Pick<
APMOSSConfig,
| 'sourcemapIndices'
| 'errorIndices'
| 'transactionIndices'
| 'spanIndices'
| 'metricsIndices'
| 'onboardingIndices'
>;

export const extractIndexPatterns = (apmConfig: APMOSSConfig): string[] => {
const indexConfigs = pick<APMIndexConfig, APMOSSConfig>(apmConfig, [
'sourcemapIndices',
'errorIndices',
'transactionIndices',
'spanIndices',
'metricsIndices',
'onboardingIndices',
]);

return uniq(Object.values(indexConfigs));
};

0 comments on commit 7f09433

Please sign in to comment.