Feature toggles management: Define get feature toggles api (#72106)
* Feature Toggle Management: Define get feature toggles api * lint
This commit is contained in:
@@ -457,6 +457,9 @@ const (
|
||||
// Alerting provisioning actions
|
||||
ActionAlertingProvisioningRead = "alert.provisioning:read"
|
||||
ActionAlertingProvisioningWrite = "alert.provisioning:write"
|
||||
|
||||
// Feature Management actions
|
||||
ActionFeatureManagementRead = "featuremgmt.read"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user