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
+3
View File
@@ -457,6 +457,9 @@ const (
// Alerting provisioning actions
ActionAlertingProvisioningRead = "alert.provisioning:read"
ActionAlertingProvisioningWrite = "alert.provisioning:write"
// Feature Management actions
ActionFeatureManagementRead = "featuremgmt.read"
)
var (
+3
View File
@@ -113,4 +113,7 @@ type FeatureFlag struct {
RequiresLicense bool `json:"requiresLicense,omitempty"` // Must be enabled in the license
FrontendOnly bool `json:"frontend,omitempty"` // change is only seen in the frontend
HideFromDocs bool `json:"hideFromDocs,omitempty"` // don't add the values to docs
Enabled bool `json:"enabled,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
}
+3 -1
View File
@@ -153,6 +153,7 @@ func (fm *FeatureManager) GetFlags() []FeatureFlag {
// WithFeatures([]interface{}{"my_feature", "other_feature"}) or WithFeatures([]interface{}{"my_feature", true})
func WithFeatures(spec ...interface{}) *FeatureManager {
count := len(spec)
features := make(map[string]*FeatureFlag, count)
enabled := make(map[string]bool, count)
idx := 0
@@ -165,10 +166,11 @@ func WithFeatures(spec ...interface{}) *FeatureManager {
idx++
}
features[key] = &FeatureFlag{Name: key, Enabled: val}
if val {
enabled[key] = true
}
}
return &FeatureManager{enabled: enabled}
return &FeatureManager{enabled: enabled, flags: features}
}