just do it

This commit is contained in:
Will Browne
2024-10-24 10:49:07 +01:00
parent 3523289e98
commit 367bfdddfe
13 changed files with 211 additions and 12 deletions
+8
View File
@@ -151,6 +151,13 @@ type FrontendSettingsSqlConnectionLimitsDTO struct {
ConnMaxLifetime int `json:"connMaxLifetime"`
}
type DependencyInfo struct {
PluginID string `json:"pluginId"`
PluginName string `json:"pluginName"`
PluginType string `json:"pluginType"`
PluginVersion string `json:"pluginVersion"`
}
type FrontendSettingsDTO struct {
DefaultDatasource string `json:"defaultDatasource"`
Datasources map[string]plugins.DataSourceDTO `json:"datasources"`
@@ -236,6 +243,7 @@ type FrontendSettingsDTO struct {
SnapshotEnabled bool `json:"snapshotEnabled"`
SecureSocksDSProxyEnabled bool `json:"secureSocksDSProxyEnabled"`
ReportingStaticContext map[string]string `json:"reportingStaticContext"`
PluginDependencies map[string][]DependencyInfo `json:"pluginDependants"`
Azure FrontendSettingsAzureDTO `json:"azure"`
+22
View File
@@ -242,6 +242,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
LocalFileSystemAvailable: hs.Cfg.LocalFileSystemAvailable,
ReportingStaticContext: hs.Cfg.ReportingStaticContext,
ExploreDefaultTimeOffset: hs.Cfg.ExploreDefaultTimeOffset,
PluginDependencies: pluginDependencyMap(c.Req.Context(), hs.pluginStore),
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{
HideVersion: hideVersion,
@@ -765,3 +766,24 @@ func (hs *HTTPServer) getEnabledOAuthProviders() map[string]any {
}
return providers
}
// pluginDependencyMap returns a map of dependant plugin IDs to their parent.
func pluginDependencyMap(ctx context.Context, pluginStore pluginstore.Store) map[string][]dtos.DependencyInfo {
dependencies := make(map[string][]dtos.DependencyInfo)
for _, plugin := range pluginStore.Plugins(ctx) {
for _, dep := range plugin.Dependencies.Plugins {
if _, exists := dependencies[dep.ID]; !exists {
dependencies[dep.ID] = []dtos.DependencyInfo{}
}
dependencies[dep.ID] = append(dependencies[dep.ID], dtos.DependencyInfo{
PluginID: plugin.ID,
PluginVersion: plugin.Info.Version,
PluginName: plugin.Name,
PluginType: string(plugin.Type),
})
}
}
return dependencies
}