Skip to content

Commit

Permalink
Adds plugin version check to kibana startup
Browse files Browse the repository at this point in the history
  • Loading branch information
BigFunger committed Sep 14, 2016
1 parent ae492ff commit 83d0821
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/server/kbn_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),

Expand Down
34 changes: 34 additions & 0 deletions src/server/plugins/check_version.js
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit 83d0821

Please sign in to comment.