-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
index.ts
67 lines (61 loc) · 1.97 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { Legacy } from 'kibana';
import { resolve } from 'path';
import { PLUGIN } from './common';
import { Plugin as RemoteClustersPlugin } from './plugin';
import { createShim } from './shim';
export function remoteClusters(kibana: any) {
return new kibana.Plugin({
id: PLUGIN.ID,
configPrefix: 'xpack.remote_clusters',
publicDir: resolve(__dirname, 'public'),
// xpack_main is required for license checking.
require: ['kibana', 'elasticsearch', 'xpack_main', 'index_management'],
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
managementSections: ['plugins/remote_clusters'],
injectDefaultVars(server: Legacy.Server) {
const config = server.config();
return {
remoteClustersUiEnabled: config.get('xpack.remote_clusters.ui.enabled'),
};
},
},
config(Joi: any) {
return Joi.object({
// display menu item
ui: Joi.object({
enabled: Joi.boolean().default(true),
}).default(),
// enable plugin
enabled: Joi.boolean().default(true),
}).default();
},
isEnabled(config: any) {
return (
config.get('xpack.remote_clusters.enabled') && config.get('xpack.index_management.enabled')
);
},
init(server: Legacy.Server) {
const {
coreSetup,
pluginsSetup: {
license: { registerLicenseChecker },
},
} = createShim(server, PLUGIN.ID);
const remoteClustersPlugin = new RemoteClustersPlugin();
// Set up plugin.
remoteClustersPlugin.setup(coreSetup);
registerLicenseChecker(
server,
PLUGIN.ID,
PLUGIN.getI18nName(),
PLUGIN.MINIMUM_LICENSE_REQUIRED
);
},
});
}