mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
34266cd369
Enables adding a section `plugin.<plugin id>` and key/value to Grafana configuration file which will be converted and sent as environment variables to the backend plugin. Also sends some additional environment variables, Grafana version (GF_VERSION), Grafana edition (GF_EDITION) and enterprise license path (GF_ENTERPRISE_LICENSE_PATH). Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Fixes #21515,
26 lines
524 B
Go
26 lines
524 B
Go
package setting
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"gopkg.in/ini.v1"
|
|
)
|
|
|
|
// PluginSettings maps plugin id to map of key/value settings.
|
|
type PluginSettings map[string]map[string]string
|
|
|
|
func extractPluginSettings(sections []*ini.Section) PluginSettings {
|
|
psMap := PluginSettings{}
|
|
for _, section := range sections {
|
|
sectionName := section.Name()
|
|
if !strings.HasPrefix(sectionName, "plugin.") {
|
|
continue
|
|
}
|
|
|
|
pluginID := strings.Replace(sectionName, "plugin.", "", 1)
|
|
psMap[pluginID] = section.KeysHash()
|
|
}
|
|
|
|
return psMap
|
|
}
|