Feature toggles management: Define get feature toggles api (#72106)

* Feature Toggle Management: Define get feature toggles api

* lint
This commit is contained in:
João Calisto
2023-07-24 16:12:59 -04:00
committed by GitHub
parent 425c92a92b
commit 4ba83173ea
11 changed files with 206 additions and 2 deletions
+5
View File
@@ -551,6 +551,9 @@ type Cfg struct {
// This needs to be on the global object since its used in the
// sqlstore package and HTTP middlewares.
DatabaseInstrumentQueries bool
// Feature Management Settings
FeatureManagement FeatureMgmtSettings
}
// AddChangePasswordLink returns if login form is disabled or not since
@@ -1236,6 +1239,8 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
logSection := iniFile.Section("log")
cfg.UserFacingDefaultError = logSection.Key("user_facing_default_error").MustString("please inspect Grafana server log for details")
cfg.readFeatureManagementConfig()
return nil
}
+32
View File
@@ -0,0 +1,32 @@
package setting
import (
"github.com/grafana/grafana/pkg/util"
)
type FeatureMgmtSettings struct {
HiddenToggles map[string]struct{}
ReadOnlyToggles map[string]struct{}
}
func (cfg *Cfg) readFeatureManagementConfig() {
section := cfg.Raw.Section("feature_management")
hiddenToggles := make(map[string]struct{})
readOnlyToggles := make(map[string]struct{})
// parse the comma separated list in `hidden_toggles`.
hiddenTogglesStr := valueAsString(section, "hidden_toggles", "")
for _, feature := range util.SplitString(hiddenTogglesStr) {
hiddenToggles[feature] = struct{}{}
}
// parse the comma separated list in `read_only_toggles`.
readOnlyTogglesStr := valueAsString(section, "read_only_toggles", "")
for _, feature := range util.SplitString(readOnlyTogglesStr) {
readOnlyToggles[feature] = struct{}{}
}
cfg.FeatureManagement.HiddenToggles = hiddenToggles
cfg.FeatureManagement.ReadOnlyToggles = readOnlyToggles
}