Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving unused settings bug when plugin is disabled #10246

Merged
merged 3 commits into from
Feb 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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