mirror of
https://github.com/grafana/grafana.git
synced 2024-12-29 10:21:41 -06:00
e31cb93ec0
* NewIA: Plugin nav config * progress * Progress * Things are working * Add monitoring node * Add alerts and incidents * added experiment with standalone page * Refactoring by adding a type for navtree root * First test working * More tests * more tests * Progress on richer config and sorting * Sort weight working * Path config * Improving logic for not including admin or cfg nodes, making it the last step so that enterprise can add admin nodes without having to worry about the section not existing * fixed index routes * removed file * Fixes * Fixing tests * Fixing more tests and adding support for weight config * Updates * Remove unused fake * More fixes * Minor tweak * Minor fix * Can now control position using sortweight even when existing items have no sortweight * Added tests for frontend standalone page logic * more tests * Remove unused fake and fixed lint issue * Moving reading settings to navtree impl package * remove nav_id setting prefix * Remove old test file * Fix trailing newline * Fixed bug with adding nil node * fixing lint issue * remove some code we have to rethink * move read settings to PrivideService and switch to util.SplitString
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
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
|
|
}
|
|
|
|
func (cfg *Cfg) readPluginSettings(iniFile *ini.File) error {
|
|
pluginsSection := iniFile.Section("plugins")
|
|
cfg.PluginsEnableAlpha = pluginsSection.Key("enable_alpha").MustBool(false)
|
|
cfg.PluginsAppsSkipVerifyTLS = pluginsSection.Key("app_tls_skip_verify_insecure").MustBool(false)
|
|
cfg.PluginSettings = extractPluginSettings(iniFile.Sections())
|
|
|
|
pluginsAllowUnsigned := pluginsSection.Key("allow_loading_unsigned_plugins").MustString("")
|
|
|
|
for _, plug := range strings.Split(pluginsAllowUnsigned, ",") {
|
|
plug = strings.TrimSpace(plug)
|
|
cfg.PluginsAllowUnsigned = append(cfg.PluginsAllowUnsigned, plug)
|
|
}
|
|
|
|
cfg.PluginCatalogURL = pluginsSection.Key("plugin_catalog_url").MustString("https://grafana.com/grafana/plugins/")
|
|
cfg.PluginAdminEnabled = pluginsSection.Key("plugin_admin_enabled").MustBool(true)
|
|
cfg.PluginAdminExternalManageEnabled = pluginsSection.Key("plugin_admin_external_manage_enabled").MustBool(false)
|
|
catalogHiddenPlugins := pluginsSection.Key("plugin_catalog_hidden_plugins").MustString("")
|
|
|
|
for _, plug := range strings.Split(catalogHiddenPlugins, ",") {
|
|
plug = strings.TrimSpace(plug)
|
|
cfg.PluginCatalogHiddenPlugins = append(cfg.PluginCatalogHiddenPlugins, plug)
|
|
}
|
|
|
|
return nil
|
|
}
|