Skip to content

Commit

Permalink
Resolving unused settings bug when plugin is disabled (#10290)
Browse files Browse the repository at this point in the history
Backports PR #10246

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

* Original sha: c829139
* 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 c829139.

* Original sha: 81538f4
* 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: 7e66762
* Authored by kobelb <brandon.kobel@elastic.co> on 2017-02-08T22:28:41Z
  • Loading branch information
elastic-jasper authored and kobelb committed Feb 10, 2017
1 parent e928a3d commit 0af938b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/server/plugins/plugin_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 {
Expand Down Expand Up @@ -60,7 +65,7 @@ module.exports = class Plugins extends Collection {
}

async disable(plugin) {
removePluginConfig(this, plugin);
disablePluginConfig(this, plugin);
this.delete(plugin);
}

Expand Down

0 comments on commit 0af938b

Please sign in to comment.