Plugins: Add hide_angular_deprecation setting (#79296)
* Add plugins.hide_angular_deprecation config ini * Add more tests * Remove the ability to use [plugins.*] hide_angular_deprecation
This commit is contained in:
@@ -246,6 +246,7 @@ type Cfg struct {
|
||||
PluginForcePublicKeyDownload bool
|
||||
PluginSkipPublicKeyDownload bool
|
||||
DisablePlugins []string
|
||||
HideAngularDeprecation []string
|
||||
PluginInstallToken string
|
||||
|
||||
PluginsCDNURLTemplate string
|
||||
|
||||
@@ -48,6 +48,15 @@ func (cfg *Cfg) readPluginSettings(iniFile *ini.File) error {
|
||||
}
|
||||
}
|
||||
|
||||
hideAngularDeprecation := pluginsSection.Key("hide_angular_deprecation").MustString("")
|
||||
for _, id := range strings.Split(hideAngularDeprecation, ",") {
|
||||
id = strings.TrimSpace(id)
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
cfg.HideAngularDeprecation = append(cfg.HideAngularDeprecation, id)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -43,18 +43,23 @@ func TestPluginSettings(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_readPluginSettings(t *testing.T) {
|
||||
t.Run("should parse disable_plugins", func(t *testing.T) {
|
||||
t.Run("should parse plugin ids", func(t *testing.T) {
|
||||
cfg := NewCfg()
|
||||
sec, err := cfg.Raw.NewSection("plugins")
|
||||
require.NoError(t, err)
|
||||
_, err = sec.NewKey("disable_plugins", "plugin1,plugin2")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = sec.NewKey("plugin_catalog_hidden_plugins", "plugin3")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = sec.NewKey("hide_angular_deprecation", "a,b,c")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = cfg.readPluginSettings(cfg.Raw)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"plugin1", "plugin2"}, cfg.DisablePlugins)
|
||||
require.Equal(t, []string{"plugin3", "plugin1", "plugin2"}, cfg.PluginCatalogHiddenPlugins)
|
||||
require.Equal(t, []string{"a", "b", "c"}, cfg.HideAngularDeprecation)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user