Conversation
5d1fbee to
4d0516d
Compare
Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud SHAHROKNI <seyedmahmoud.shahrokni@amadeus.com>
4d0516d to
d604ac7
Compare
| metadata: { | ||
| name: 'Fake Plugin Module for Tests', | ||
| version: '0', | ||
| registry: '', |
There was a problem hiding this comment.
this could be undefined rather than empty.
|
|
||
| for (const plugin of resource.spec.plugins) { | ||
| const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name, pluginsAssetsPath); | ||
| const remotePluginModule = await loadPlugin( |
There was a problem hiding this comment.
If we are changing the signature, probably is better to use an object
|
|
||
| // Index the plugin by type and kind to point at the module that contains it | ||
| const key = getTypeAndKindKey(kind, name); | ||
| const key = getTypeAndKindKey(kind, name, registry || '', version || ''); |
There was a problem hiding this comment.
maybe is better that the function can accept undefined values and will resolve the key, rather than adding logic to the parameters. Also it would be better to use an object so is more readable
| /* | ||
| Question: Why does it register the remote with the module name?! | ||
| This way the URL will be based on the module name and not the plugin! | ||
| Unless => the backend has a map of plugins with the module key, And when `${moduleName}/${pluginName}` is called the, the plugin can be found with version and registry |
There was a problem hiding this comment.
actually the backend is storing the plugins in two different ways.
As an entry point in the plugin management, the plugins are registered using the plugin module name / plugin module registry. And then with this key, you have the list of version registered.
Then for the schema management per plugins, the key is the actual name of the plugin (not anymore the plugin module name) with the registry. Which give you access of a list of the various version supported for the given schema.
The same logic apply for the migration script.
But if you want to simplify this vision, the key / entrypoint in the plugin registry is the plugin module name + registry.
For example, if you consider the Prometheus plugin, it is actually a module that contains multiple plugins. So Prometheus is the name of the module and (for example) PrometheusTimeseriesQuery is one of the plugin provided by this module.
But for the frontend when getting the js files for the PrometheusTimeseriesQuery plugin, it will actually call the backend with the name of the module Prometheus and not PrometheusTimeseriesQuery because the js files of this particular plugin are mixed up with the rest of others plugin contained in the module. And the backend cannot give you exactly the files for this particular plugin, only for the module and then frontend is finding the one it is looking for.
Is it clearer or on the contrary even more fuzzy ?
| 1, | ||
| 'multi-plugin-module', | ||
| 'plugin1', | ||
| undefined, |
There was a problem hiding this comment.
an object parameter will avoid this undefined, undefined fields
|
Thank you @shahrokni for updating the frontend regarding the plugin multi version management ! Indeed the backend will need to be updated at some point, but hopefully that should be as easy as to update the regexp capturingPluginName = regexp.MustCompile(`/plugins/([a-zA-Z0-9_-]+)/?.*`)to catch the registry and the version. |
|
|
||
| Conclusion: | ||
| If my assumption is correct, I follow the same pattern and add the version and registry to the URL. | ||
| In my opinion: it would be better to be moduleName/pluginName/registry/version At least for readability? |
There was a problem hiding this comment.
We don't load individual plugins, we load the whole plugin module, which has specific plugin exports internally.
| import { PersesPlugin, RemotePluginModule } from './PersesPlugin.types'; | ||
|
|
||
| export const DEFAULT_PLUGIN_REGISTRY = 'perses.dev'; | ||
| export const DEFAULT_PLUGIN_VERSION = 'latest'; |
There was a problem hiding this comment.
IIUC from the backend, the default version is empty for backwards compatibility, which means the latest version.
| pluginLoader: { getInstalledPlugins, importPluginModule }, | ||
| children, | ||
| defaultPluginKinds, | ||
| pluginPreferences, |
There was a problem hiding this comment.
is this needed? the plugin versions are defined inside dashboards, if not defined it will use whatever is available in the backend.
| export interface PluginModuleMetadata { | ||
| name: string; | ||
| version: string; | ||
| registry: string; |
There was a problem hiding this comment.
this will break existing plugins, we probably want this to be optional.
There was a problem hiding this comment.
yeah this can be optional. It is the case in the equivalent go struct
| import * as ReactRouterDOM from 'react-router-dom'; | ||
| import { PersesPlugin, RemotePluginModule } from './PersesPlugin.types'; | ||
|
|
||
| export const DEFAULT_PLUGIN_REGISTRY = 'perses.dev'; |
There was a problem hiding this comment.
Not sure how this is handled in the backend, but this won't be a valid url path unless escaped. By default this is probably empty to use the core plugins
There was a problem hiding this comment.
by default if it is empty, then the value is equal to perses.dev
perses/perses#1186
Different Plugins Versions and Registries
So far a plugin could be imported by its name only.
The backend has recently introduced a feature by which multiple versions of the same plugin could be available.
This means if the consumer of the Plugin Registry provided the version and registry, the exact desired plugin could be loaded in the front!
To achieve the mentioned goal the new URL will carry the version and registry as well. If not provided by the consumer, the front uses the default values introduced by the backend which are latest and perses.dev
Backend should be adjusted to manage the new URL. I checked the backend and understood that at the moment the intercepted GET request is translated to the address of the files on the disk. Please take a look at (ui\endpoint.go)
I believe the following shared code should be adjusted for the new URL that I just explained.
There is also a TODO comment in backend that I believe could to be addressed now
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: