-
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
Add mechansim for legacy plugins to depend on New Platform plugins #42948
Comments
Pinging @elastic/kibana-platform |
New platform plugins have a notion of lifecycle contracts. What type of contracts should be exposed to the Legacy plugins? setup/start/both? on both client and server sides? |
On the client side, we're currently exposing both the setup and start contracts. There could be issues with this since no legacy code runs on the client side until after the start lifecycle. Alternatively, we could remove this bridge completely and require that legacy plugins depend on a shimmed version of the NP plugin. |
One possible solution to this is to create an API that allows any arbitrary code to get a version of the Core APIs defined for a "dynamic" plugin that does not "exist" in the New Platform proper, but is added later. Example: interface CoreSetup {
runPlugin(plugin: {
/** Support parts of the kibana.json manifest for the dynamically added plugin */
manifest: Pick<PluginManifest, 'id' | 'configPath' | 'requiredPlugins' | 'optionalPlugins'>;
/** Config schema for the plugin's configuration */
schema: Schema;
/** Function used to create a new Plugin instance */
init(initializerContext: PluginInitializerContext): Plugin;
/**
* Extra fields to be merged with the default core & plugin services.
* Used to shim services that have not yet been migrated to the New Platform.
*/
extras?: DeepPartial<{
setup: { core: object; plugins: object };
start: { core: object; plugins: object };
}>;
}): boolean;
} The core.runPlugin({
manifest: {
id: 'my-legacy-plugin',
requiredPlugins: ['data']
},
schema: schema.object({ myConfigField: schema.string() }),
plugin: (initializerContext) => new MyLegacyPlugin(initializerContext),
extras: {
setup: {
plugins: { legacyPluginA }
}
}
}); Behavior:
Some caveats:
|
We discussed this offline this week and have decided that the work required to add this I will do some investigation on what the behavior should be when a LP plugin has a dependency on an NP plugin and how it should handle the situation where that NP plugin is disabled. |
@joshdover Was there an outcome on this yet, or any recommendations for how folks should be addressing it? |
Can we just do this by checking that |
Apologies, I forgot to update this issue. Specifying dependencies is really two things:
During their It would be pretty trivial to add a property to the legacy plugin definition that could list the NP dependencies to do this crashing automatically. If we think this is a common case, then feel free to open this issue. |
I don't think it's a huge deal to crash your plugin manually in It may be worth documenting/communicating this as a best practice to reduce the likelihood of bugs coming up in |
Currently, legacy plugins can define their dependencies on other plugins via the
require
parameter passed to thekibana.Plugin
constructor. If any of these dependencies are missing or disabled, Kibana refuses to start with the error:With the migration effort, legacy plugins should be able to use New Platform plugins as dependencies (but not the other way around). This allows plugin developers to gradually move over functionality or extract common code into NP plugins before moving over the entire legacy plugin.
This creates a problem because these dependencies are not known and if the NP plugin that is being depended on is disabled, the legacy plugin that depends on it will produce errors at runtime rather than when Kibana starts.
Proposal
Add a new
requireNewPlatform
parameter to thekibana.Plugin
constructor that behaves similarly to therequire
parameter and will refuse to start Kibana if some New Platform plugin is not present.The text was updated successfully, but these errors were encountered: