From e920bca051b51ffc0245ebe2e6427309a080285a Mon Sep 17 00:00:00 2001 From: Jim Unger Date: Thu, 15 Sep 2016 16:04:41 -0500 Subject: [PATCH] Adds a kibanaVersion property to the Plugin class --- src/server/plugins/check_version.js | 16 ++++++---------- src/server/plugins/plugin.js | 6 ++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/server/plugins/check_version.js b/src/server/plugins/check_version.js index 84b56a417660..6f8f737f3e19 100644 --- a/src/server/plugins/check_version.js +++ b/src/server/plugins/check_version.js @@ -1,14 +1,14 @@ import { cleanVersion, versionSatisfies } from '../../utils/version'; import { get } from 'lodash'; -function compatibleWithKibana(kbnServer, pluginVersion) { +function compatibleWithKibana(kbnServer, plugin) { //core plugins have a version of 'kibana' and are always compatible - if (pluginVersion === 'kibana') return true; + if (plugin.kibanaVersion === 'kibana') return true; - const cleanPluginVersion = cleanVersion(pluginVersion); + const pluginKibanaVersion = cleanVersion(plugin.kibanaVersion); const kibanaVersion = cleanVersion(kbnServer.version); - return versionSatisfies(cleanPluginVersion, kibanaVersion); + return versionSatisfies(pluginKibanaVersion, kibanaVersion); } export default async function (kbnServer, server, config) { @@ -18,14 +18,10 @@ export default async function (kbnServer, server, config) { 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 version = plugin.kibanaVersion; const name = get(plugin, 'pkg.name'); - if (!compatibleWithKibana(kbnServer, version)) { + if (!compatibleWithKibana(kbnServer, plugin)) { const message = `Plugin "${name}" was disabled because it expected Kibana version "${version}", and found "${kbnServer.version}".`; warningMessages.add(message); plugins.delete(plugin); diff --git a/src/server/plugins/plugin.js b/src/server/plugins/plugin.js index 1ea4cec6e2fd..b6912806b59e 100644 --- a/src/server/plugins/plugin.js +++ b/src/server/plugins/plugin.js @@ -59,6 +59,12 @@ module.exports = class Plugin { this.uiExportsSpecs = opts.uiExports || {}; this.requiredIds = opts.require || []; this.version = opts.version || pkg.version; + + // 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 in the package to indicate the + // version of kibana the plugin is intended to work with. + this.kibanaVersion = opts.kibanaVersion || _.get(pkg, 'kibana.version', this.version); this.externalPreInit = opts.preInit || _.noop; this.externalInit = opts.init || _.noop; this.configPrefix = opts.configPrefix || this.id;