-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Plugins: Add preInit capability #7069
Conversation
@@ -40,6 +40,10 @@ module.exports = async function (kbnServer, server, config) { | |||
path.pop(); | |||
}; | |||
|
|||
for (let plugin of plugins) { | |||
await plugin.preInit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does pre-initialization not require to follow the same plugin dependency graph as initialization does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the current use case, it doesn't, but I could see why that might be necessary. What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, I'm against implementing something we don't need for a current use case (speculative generality is a code smell). In this case, however, implementing pre-initialization to parallel initialization would lend consistency to the codebase, and make it easier to reason about IMO.
Looks reasonable to me.... I'd merge it |
Thanks @lukasolson. The change looks good. Would it be possible to add unit tests here to prove that all the pre-inits for a set of plugins are called before all the inits? |
I'm on it. |
jenkins, test it |
LGTM |
jenkins, test it |
This PR adds the capability for a plugin to have a
preInit
function which is invoked prior to callinginit
on any of the other registered plugins.One use case for this is to enable a plugin to programmatically override options that another plugin provides.