mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Alerting] Migrate Event Log plugin to TS project references (#81557)
* [Alerting] Migrate Event Log plugin to TS project references * fixed faling typechecks * fixed path to spaces plugin ts file * fixed missing include * added fix for mapping.json * replaced package.json get version with kibanaVersion from plugin initial context * fixed build * fixed typechecks * fixed tests
This commit is contained in:
parent
c66c9424d9
commit
5c112b8b5a
10 changed files with 49 additions and 13 deletions
|
@ -25,6 +25,7 @@ describe('createEsContext', () => {
|
|||
logger,
|
||||
clusterClientPromise: Promise.resolve(clusterClient),
|
||||
indexNameRoot: 'test0',
|
||||
kibanaVersion: '1.2.3',
|
||||
});
|
||||
|
||||
expect(context.initialized).toBeFalsy();
|
||||
|
@ -38,6 +39,7 @@ describe('createEsContext', () => {
|
|||
logger,
|
||||
clusterClientPromise: Promise.resolve(clusterClient),
|
||||
indexNameRoot: 'test-index',
|
||||
kibanaVersion: '1.2.3',
|
||||
});
|
||||
|
||||
const esNames = context.esNames;
|
||||
|
@ -57,6 +59,7 @@ describe('createEsContext', () => {
|
|||
logger,
|
||||
clusterClientPromise: Promise.resolve(clusterClient),
|
||||
indexNameRoot: 'test1',
|
||||
kibanaVersion: '1.2.3',
|
||||
});
|
||||
clusterClient.callAsInternalUser.mockResolvedValue(false);
|
||||
|
||||
|
@ -74,6 +77,7 @@ describe('createEsContext', () => {
|
|||
logger,
|
||||
clusterClientPromise: Promise.resolve(clusterClient),
|
||||
indexNameRoot: 'test2',
|
||||
kibanaVersion: '1.2.3',
|
||||
});
|
||||
clusterClient.callAsInternalUser.mockResolvedValue(true);
|
||||
context.initialize();
|
||||
|
@ -98,6 +102,7 @@ describe('createEsContext', () => {
|
|||
logger,
|
||||
clusterClientPromise: Promise.resolve(clusterClient),
|
||||
indexNameRoot: 'test2',
|
||||
kibanaVersion: '1.2.3',
|
||||
});
|
||||
context.initialize();
|
||||
const success = await context.waitTillReady();
|
||||
|
|
|
@ -36,6 +36,7 @@ export interface EsContextCtorParams {
|
|||
logger: Logger;
|
||||
clusterClientPromise: Promise<EsClusterClient>;
|
||||
indexNameRoot: string;
|
||||
kibanaVersion: string;
|
||||
}
|
||||
|
||||
class EsContextImpl implements EsContext {
|
||||
|
@ -47,7 +48,7 @@ class EsContextImpl implements EsContext {
|
|||
|
||||
constructor(params: EsContextCtorParams) {
|
||||
this.logger = params.logger;
|
||||
this.esNames = getEsNames(params.indexNameRoot);
|
||||
this.esNames = getEsNames(params.indexNameRoot, params.kibanaVersion);
|
||||
this.readySignal = createReadySignal();
|
||||
this.initialized = false;
|
||||
this.esAdapter = new ClusterClientAdapter({
|
||||
|
|
|
@ -18,7 +18,8 @@ describe('getIlmPolicy()', () => {
|
|||
});
|
||||
|
||||
describe('getIndexTemplate()', () => {
|
||||
const esNames = getEsNames('XYZ');
|
||||
const kibanaVersion = '1.2.3';
|
||||
const esNames = getEsNames('XYZ', kibanaVersion);
|
||||
|
||||
test('returns the correct details of the index template', () => {
|
||||
const indexTemplate = getIndexTemplate(esNames);
|
||||
|
|
|
@ -13,20 +13,22 @@ jest.mock('../lib/../../../../package.json', () => ({
|
|||
describe('getEsNames()', () => {
|
||||
test('works as expected', () => {
|
||||
const base = 'XYZ';
|
||||
const version = '1.2.3';
|
||||
const esNames = getEsNames(base);
|
||||
const kibanaVersion = '1.2.3';
|
||||
const esNames = getEsNames(base, kibanaVersion);
|
||||
expect(esNames.base).toEqual(base);
|
||||
expect(esNames.alias).toEqual(`${base}-event-log-${version}`);
|
||||
expect(esNames.alias).toEqual(`${base}-event-log-${kibanaVersion}`);
|
||||
expect(esNames.ilmPolicy).toEqual(`${base}-event-log-policy`);
|
||||
expect(esNames.indexPattern).toEqual(`${base}-event-log-*`);
|
||||
expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${version}-*`);
|
||||
expect(esNames.initialIndex).toEqual(`${base}-event-log-${version}-000001`);
|
||||
expect(esNames.indexTemplate).toEqual(`${base}-event-log-${version}-template`);
|
||||
expect(esNames.indexPatternWithVersion).toEqual(`${base}-event-log-${kibanaVersion}-*`);
|
||||
expect(esNames.initialIndex).toEqual(`${base}-event-log-${kibanaVersion}-000001`);
|
||||
expect(esNames.indexTemplate).toEqual(`${base}-event-log-${kibanaVersion}-template`);
|
||||
});
|
||||
|
||||
test('ilm policy name does not contain dot prefix', () => {
|
||||
const base = '.XYZ';
|
||||
const esNames = getEsNames(base);
|
||||
const kibanaVersion = '1.2.3';
|
||||
|
||||
const esNames = getEsNames(base, kibanaVersion);
|
||||
expect(esNames.ilmPolicy).toEqual('XYZ-event-log-policy');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import xPackage from '../../../../package.json';
|
||||
|
||||
const EVENT_LOG_NAME_SUFFIX = `-event-log`;
|
||||
const EVENT_LOG_VERSION_SUFFIX = `-${xPackage.version}`;
|
||||
|
||||
export interface EsNames {
|
||||
base: string;
|
||||
|
@ -19,7 +16,8 @@ export interface EsNames {
|
|||
indexTemplate: string;
|
||||
}
|
||||
|
||||
export function getEsNames(baseName: string): EsNames {
|
||||
export function getEsNames(baseName: string, kibanaVersion: string): EsNames {
|
||||
const EVENT_LOG_VERSION_SUFFIX = `-${kibanaVersion.toLocaleLowerCase()}`;
|
||||
const eventLogName = `${baseName}${EVENT_LOG_NAME_SUFFIX}`;
|
||||
const eventLogNameWithVersion = `${eventLogName}${EVENT_LOG_VERSION_SUFFIX}`;
|
||||
const eventLogPolicyName = `${
|
||||
|
|
|
@ -55,12 +55,14 @@ export class Plugin implements CorePlugin<IEventLogService, IEventLogClientServi
|
|||
private globalConfig$: Observable<SharedGlobalConfig>;
|
||||
private eventLogClientService?: EventLogClientService;
|
||||
private savedObjectProviderRegistry: SavedObjectProviderRegistry;
|
||||
private kibanaVersion: PluginInitializerContext['env']['packageInfo']['version'];
|
||||
|
||||
constructor(private readonly context: PluginInitializerContext) {
|
||||
this.systemLogger = this.context.logger.get();
|
||||
this.config$ = this.context.config.create<IEventLogConfig>();
|
||||
this.globalConfig$ = this.context.config.legacy.globalConfig$;
|
||||
this.savedObjectProviderRegistry = new SavedObjectProviderRegistry();
|
||||
this.kibanaVersion = this.context.env.packageInfo.version;
|
||||
}
|
||||
|
||||
async setup(core: CoreSetup): Promise<IEventLogService> {
|
||||
|
@ -78,6 +80,7 @@ export class Plugin implements CorePlugin<IEventLogService, IEventLogClientServi
|
|||
clusterClientPromise: core
|
||||
.getStartServices()
|
||||
.then(([{ elasticsearch }]) => elasticsearch.legacy.client),
|
||||
kibanaVersion: this.kibanaVersion,
|
||||
});
|
||||
|
||||
this.eventLogService = new EventLogService({
|
||||
|
|
22
x-pack/plugins/event_log/tsconfig.json
Normal file
22
x-pack/plugins/event_log/tsconfig.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "./target/types",
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
},
|
||||
"include": [
|
||||
"server/**/*",
|
||||
"scripts/**/*",
|
||||
"generated/*",
|
||||
// have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636
|
||||
"generated/*.json",
|
||||
"common/*"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../../../src/core/tsconfig.json" },
|
||||
{ "path": "../spaces/tsconfig.json" }
|
||||
]
|
||||
}
|
|
@ -42,6 +42,7 @@
|
|||
{ "path": "../plugins/global_search_providers/tsconfig.json" },
|
||||
{ "path": "../plugins/features/tsconfig.json" },
|
||||
{ "path": "../plugins/embeddable_enhanced/tsconfig.json" },
|
||||
{ "path": "../plugins/event_log/tsconfig.json"},
|
||||
{ "path": "../plugins/licensing/tsconfig.json" },
|
||||
{ "path": "../plugins/task_manager/tsconfig.json" },
|
||||
{ "path": "../plugins/telemetry_collection_xpack/tsconfig.json" },
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"plugins/graph/**/*",
|
||||
"plugins/features/**/*",
|
||||
"plugins/embeddable_enhanced/**/*",
|
||||
"plugins/event_log/**/*",
|
||||
"plugins/licensing/**/*",
|
||||
"plugins/searchprofiler/**/*",
|
||||
"plugins/security_solution/cypress/**/*",
|
||||
|
@ -73,6 +74,7 @@
|
|||
{ "path": "./plugins/features/tsconfig.json" },
|
||||
{ "path": "./plugins/graph/tsconfig.json" },
|
||||
{ "path": "./plugins/embeddable_enhanced/tsconfig.json" },
|
||||
{ "path": "./plugins/event_log/tsconfig.json"},
|
||||
{ "path": "./plugins/licensing/tsconfig.json" },
|
||||
{ "path": "./plugins/searchprofiler/tsconfig.json" },
|
||||
{ "path": "./plugins/task_manager/tsconfig.json" },
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
{ "path": "./plugins/data_enhanced/tsconfig.json" },
|
||||
{ "path": "./plugins/global_search/tsconfig.json" },
|
||||
{ "path": "./plugins/global_search_providers/tsconfig.json" },
|
||||
{ "path": "./plugins/event_log/tsconfig.json"},
|
||||
{ "path": "./plugins/features/tsconfig.json" },
|
||||
{ "path": "./plugins/graph/tsconfig.json" },
|
||||
{ "path": "./plugins/embeddable_enhanced/tsconfig.json" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue