forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds plugin version check to kibana startup
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |