Implement plugin config prefix#6554
Conversation
- switch from maps to objects - use lodash's get/set/has - use configPrefix instead of id, if set - also adds an unset config method
src/server/config/config.js
Outdated
| if (initialVals) { | ||
| this.set(key, initialVals); | ||
| this[pendingSets].delete(key); | ||
| const path = toPath(key); |
|
LGTM |
src/server/config/config.js
Outdated
| this[schema] = Joi.object().keys(objKeys).default(); | ||
| this[schema] = (function convertToSchema(children) { | ||
| let objKeys = Object.keys(children); | ||
| let schema = Joi.object().keys(objKeys).default(); |
There was a problem hiding this comment.
passing objKeys here is unnecessary. Joi is itterating the own properties of objKeys and adding them as keys, but since it's an array it has no own properties and does nothing.
There was a problem hiding this comment.
Yup, I read the Joi docs wrong before.
The call to .keys() is required, otherwise the validation fails (and the tests do as a result), but it just needs to be given an empty object, since the actual keys are appended after the fact.
|
There appears to be what looks like a race condition here, where the keys in the schema are changing and then the validation fails. I've used this to prefix the XPack settings with And then Kibana fails due to schema issues: |
also fixes issue with recursive removal of properties
|
Issue was related to disabled plugins. Should be fixed now. @spalger I broke out the unset module and added tests, let me know if there's a scenario I missed in there though. |
|
jenkins, test it |
1 similar comment
|
jenkins, test it |
Closes #6304
Allows plugins to optionally prefix their config values via a new
configPrefixparameterWhen
configPrefixis set, it uses that value for the config values. Otherwise it uses the default, which is simply the pluginidvalue.Both of these are valid: