mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Adds plugin version check to kibana startup
This commit is contained in:
parent
ae492ff066
commit
83d0821054
2 changed files with 37 additions and 0 deletions
|
@ -28,6 +28,9 @@ module.exports = class KbnServer {
|
|||
// find plugins and set this.plugins
|
||||
require('./plugins/scan'),
|
||||
|
||||
// make sure that all plugins expect the current version of Kibana
|
||||
require('./plugins/check_version'),
|
||||
|
||||
// tell the config we are done loading plugins
|
||||
require('./config/complete'),
|
||||
|
||||
|
|
34
src/server/plugins/check_version.js
Normal file
34
src/server/plugins/check_version.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import pluginInit from './plugin_init';
|
||||
import { cleanVersion, versionSatisfies } from '../../utils/version';
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = async function (kbnServer, server, config) {
|
||||
const warningMessages = new Set();
|
||||
const plugins = kbnServer.plugins;
|
||||
|
||||
for (let plugin of plugins) {
|
||||
// Plugins must specify their version, and by default that version should match
|
||||
// the version of kibana down to the patch level. If these two versions need
|
||||
// to diverge, they can specify a kibana.version to indicate the version of
|
||||
// kibana the plugin is intended to work with.
|
||||
const version = _.get(plugin, 'pkg.kibana.version', _.get(plugin, 'pkg.version'));
|
||||
const name = _.get(plugin, 'pkg.name');
|
||||
|
||||
if (version === 'kibana') continue;
|
||||
|
||||
if (!versionSatisfies(
|
||||
cleanVersion(version),
|
||||
cleanVersion(kbnServer.version))) {
|
||||
warningMessages.add(`Plugin "${name}" expected Kibana version "${version}" and was disabled.`);
|
||||
plugins.delete(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
//because a plugin pack can contain more than one actual plugin, (for example x-pack)
|
||||
//we make sure that the warning messages are unique
|
||||
for (let message of warningMessages) {
|
||||
server.log(['warning'], message);
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue