Resolving unused settings bug when plugin is disabled (#10291)

Backports PR #10246

**Commit 1:**
Resolving unused settings bug when plugin is disabled

* Original sha: c829139732
* Authored by kobelb <brandon.kobel@elastic.co> on 2017-02-06T14:33:24Z

**Commit 2:**
Revert "Resolving unused settings bug when plugin is disabled"

This reverts commit c829139732.

* Original sha: 81538f444d
* Authored by kobelb <brandon.kobel@elastic.co> on 2017-02-08T22:16:45Z

**Commit 3:**
Replacing a disabled plugin's config with a simple schema/config with enabled set to false

* Original sha: 7e66762022
* Authored by kobelb <brandon.kobel@elastic.co> on 2017-02-08T22:28:41Z
This commit is contained in:
jasper 2017-02-10 07:39:04 -05:00 committed by Brandon Kobel
parent dd2b6f9fab
commit 8826fdd41f

View file

@ -6,6 +6,7 @@ import toPath from 'lodash/internal/toPath';
import Collection from '../../utils/collection';
import { transformDeprecations } from '../config/transform_deprecations';
import { createTransform } from '../../deprecation';
import Joi from 'joi';
const byIdCache = Symbol('byIdCache');
const pluginApis = Symbol('pluginApis');
@ -24,9 +25,13 @@ async function addPluginConfig(pluginCollection, plugin) {
config.extendSchema(configSchema, transformedPluginSettings, plugin.configPrefix);
}
function removePluginConfig(pluginCollection, plugin) {
function disablePluginConfig(pluginCollection, plugin) {
// when disabling a plugin's config we remove the existing schema and
// replace it with a simple schema/config that only has enabled set to false
const { config } = pluginCollection.kbnServer;
config.removeSchema(plugin.configPrefix);
const schema = Joi.object({ enabled: Joi.bool() });
config.extendSchema(schema, { enabled: false }, plugin.configPrefix);
}
module.exports = class Plugins extends Collection {
@ -60,7 +65,7 @@ module.exports = class Plugins extends Collection {
}
async disable(plugin) {
removePluginConfig(this, plugin);
disablePluginConfig(this, plugin);
this.delete(plugin);
}