Settings: Actually deprecate access to feature flags (#78073)

This commit is contained in:
Ryan McKinley
2023-11-13 11:39:01 -08:00
committed by GitHub
parent 4a3c148298
commit dec9a07738
15 changed files with 37 additions and 21 deletions

View File

@@ -144,7 +144,9 @@ func (o *OSSImpl) Section(section string) Section {
func (*OSSImpl) RegisterReloadHandler(string, ReloadHandler) {}
// Deprecated: use feature toggles
func (o *OSSImpl) IsFeatureToggleEnabled(name string) bool {
// nolint:staticcheck
return o.Cfg.IsFeatureToggleEnabled(name)
}

View File

@@ -361,7 +361,7 @@ type Cfg struct {
ApiKeyMaxSecondsToLive int64
// Check if a feature toggle is enabled
// @deprecated
// Deprecated: use featuremgmt.FeatureFlags
IsFeatureToggleEnabled func(key string) bool // filled in dynamically
AnonymousEnabled bool
@@ -1168,6 +1168,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
return err
}
// nolint:staticcheck
if err := cfg.readFeatureToggles(iniFile); err != nil {
return err
}

View File

@@ -8,13 +8,14 @@ import (
"github.com/grafana/grafana/pkg/util"
)
// @deprecated -- should use `featuremgmt.FeatureToggles`
// Deprecated: should use `featuremgmt.FeatureToggles`
func (cfg *Cfg) readFeatureToggles(iniFile *ini.File) error {
section := iniFile.Section("feature_toggles")
toggles, err := ReadFeatureTogglesFromInitFile(section)
if err != nil {
return err
}
// nolint:staticcheck
cfg.IsFeatureToggleEnabled = func(key string) bool { return toggles[key] }
return nil
}