Skip to content

Commit e920bca

Browse files
committed
Adds a kibanaVersion property to the Plugin class
1 parent 2f52be6 commit e920bca

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/server/plugins/check_version.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { cleanVersion, versionSatisfies } from '../../utils/version';
22
import { get } from 'lodash';
33

4-
function compatibleWithKibana(kbnServer, pluginVersion) {
4+
function compatibleWithKibana(kbnServer, plugin) {
55
//core plugins have a version of 'kibana' and are always compatible
6-
if (pluginVersion === 'kibana') return true;
6+
if (plugin.kibanaVersion === 'kibana') return true;
77

8-
const cleanPluginVersion = cleanVersion(pluginVersion);
8+
const pluginKibanaVersion = cleanVersion(plugin.kibanaVersion);
99
const kibanaVersion = cleanVersion(kbnServer.version);
1010

11-
return versionSatisfies(cleanPluginVersion, kibanaVersion);
11+
return versionSatisfies(pluginKibanaVersion, kibanaVersion);
1212
}
1313

1414
export default async function (kbnServer, server, config) {
@@ -18,14 +18,10 @@ export default async function (kbnServer, server, config) {
1818
const plugins = kbnServer.plugins;
1919

2020
for (let plugin of plugins) {
21-
// Plugins must specify their version, and by default that version should match
22-
// the version of kibana down to the patch level. If these two versions need
23-
// to diverge, they can specify a kibana.version to indicate the version of
24-
// kibana the plugin is intended to work with.
25-
const version = get(plugin, 'pkg.kibana.version', get(plugin, 'pkg.version'));
21+
const version = plugin.kibanaVersion;
2622
const name = get(plugin, 'pkg.name');
2723

28-
if (!compatibleWithKibana(kbnServer, version)) {
24+
if (!compatibleWithKibana(kbnServer, plugin)) {
2925
const message = `Plugin "${name}" was disabled because it expected Kibana version "${version}", and found "${kbnServer.version}".`;
3026
warningMessages.add(message);
3127
plugins.delete(plugin);

src/server/plugins/plugin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ module.exports = class Plugin {
5959
this.uiExportsSpecs = opts.uiExports || {};
6060
this.requiredIds = opts.require || [];
6161
this.version = opts.version || pkg.version;
62+
63+
// Plugins must specify their version, and by default that version should match
64+
// the version of kibana down to the patch level. If these two versions need
65+
// to diverge, they can specify a kibana.version in the package to indicate the
66+
// version of kibana the plugin is intended to work with.
67+
this.kibanaVersion = opts.kibanaVersion || _.get(pkg, 'kibana.version', this.version);
6268
this.externalPreInit = opts.preInit || _.noop;
6369
this.externalInit = opts.init || _.noop;
6470
this.configPrefix = opts.configPrefix || this.id;

0 commit comments

Comments
 (0)