OpenFeature: Add config setting to disable API (#108620)
* Add config option to disable ofrep api * Apply review feedback
This commit is contained in:
@@ -2016,6 +2016,7 @@ enable =
|
||||
|
||||
[feature_toggles.openfeature]
|
||||
# This is EXPERIMENTAL. Please, do not use this section
|
||||
enable_api = true
|
||||
provider = static
|
||||
|
||||
[feature_toggles.openfeature.context]
|
||||
|
||||
@@ -61,9 +61,12 @@ func NewAPIBuilder(providerType string, url *url.URL, insecure bool, caFile stri
|
||||
}
|
||||
|
||||
func RegisterAPIService(apiregistration builder.APIRegistrar, cfg *setting.Cfg) (*APIBuilder, error) {
|
||||
if !cfg.OpenFeature.APIEnabled {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var staticEvaluator featuremgmt.StaticFlagEvaluator // No static evaluator needed for non-static provider
|
||||
var err error
|
||||
|
||||
if cfg.OpenFeature.ProviderType == setting.StaticProviderType {
|
||||
staticEvaluator, err = featuremgmt.CreateStaticEvaluator(cfg)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,6 +11,7 @@ const (
|
||||
)
|
||||
|
||||
type OpenFeatureSettings struct {
|
||||
APIEnabled bool
|
||||
ProviderType string
|
||||
URL *url.URL
|
||||
TargetingKey string
|
||||
@@ -21,6 +22,7 @@ func (cfg *Cfg) readOpenFeatureSettings() error {
|
||||
cfg.OpenFeature = OpenFeatureSettings{}
|
||||
|
||||
config := cfg.Raw.Section("feature_toggles.openfeature")
|
||||
cfg.OpenFeature.APIEnabled = config.Key("enable_api").MustBool(true)
|
||||
cfg.OpenFeature.ProviderType = config.Key("provider").MustString(StaticProviderType)
|
||||
cfg.OpenFeature.TargetingKey = config.Key("targetingKey").MustString(cfg.AppURL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user