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.
Merge pull request elastic#8335 from elastic/jasper/backport/8283/5.x
[backport] PR elastic#8283 to 5.x
- Loading branch information
Showing
11 changed files
with
94 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ target | |
/esvm | ||
.htpasswd | ||
.eslintcache | ||
plugins | ||
/plugins/ | ||
data | ||
disabledPlugins | ||
webpackstats.json | ||
|
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
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,15 @@ | ||
import toPath from 'lodash/internal/toPath'; | ||
|
||
export default async function (kbnServer, server, config) { | ||
const { plugins } = kbnServer; | ||
|
||
for (let plugin of plugins) { | ||
const enabledInConfig = config.get([...toPath(plugin.configPrefix), 'enabled']); | ||
|
||
if (!enabledInConfig) { | ||
plugins.disable(plugin); | ||
} | ||
} | ||
|
||
return; | ||
}; |
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,36 @@ | ||
import { cleanVersion, versionSatisfies } from '../../utils/version'; | ||
import { get } from 'lodash'; | ||
|
||
function compatibleWithKibana(kbnServer, plugin) { | ||
//core plugins have a version of 'kibana' and are always compatible | ||
if (plugin.kibanaVersion === 'kibana') return true; | ||
|
||
const pluginKibanaVersion = cleanVersion(plugin.kibanaVersion); | ||
const kibanaVersion = cleanVersion(kbnServer.version); | ||
|
||
return versionSatisfies(pluginKibanaVersion, kibanaVersion); | ||
} | ||
|
||
export default async function (kbnServer, server, config) { | ||
//because a plugin pack can contain more than one actual plugin, (for example x-pack) | ||
//we make sure that the warning messages are unique | ||
const warningMessages = new Set(); | ||
const plugins = kbnServer.plugins; | ||
|
||
for (let plugin of plugins) { | ||
const version = plugin.kibanaVersion; | ||
const name = get(plugin, 'pkg.name'); | ||
|
||
if (!compatibleWithKibana(kbnServer, plugin)) { | ||
const message = `Plugin "${name}" was disabled because it expected Kibana version "${version}", and found "${kbnServer.version}".`; | ||
warningMessages.add(message); | ||
plugins.disable(plugin); | ||
} | ||
} | ||
|
||
for (let message of warningMessages) { | ||
server.log(['warning'], message); | ||
} | ||
|
||
return; | ||
}; |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "plugin_async_foo", | ||
"version": "0.0.0" | ||
"version": "kibana" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "plugin_bar", | ||
"version": "0.0.0" | ||
"version": "kibana" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "plugin_foo", | ||
"version": "0.0.0" | ||
"version": "kibana" | ||
} |
File renamed without changes.