|
|
|
@ -73,7 +73,8 @@ func (fm *FeatureManager) registerFlags(flags ...FeatureFlag) { |
|
|
|
|
fm.update() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (fm *FeatureManager) evaluate(ff *FeatureFlag) bool { |
|
|
|
|
// meetsRequirements checks if grafana is able to run the given feature due to dev mode or licensing requirements
|
|
|
|
|
func (fm *FeatureManager) meetsRequirements(ff *FeatureFlag) bool { |
|
|
|
|
if ff.RequiresDevMode && !fm.isDevMod { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
@ -82,19 +83,22 @@ func (fm *FeatureManager) evaluate(ff *FeatureFlag) bool { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: CEL - expression
|
|
|
|
|
return ff.Expression == "true" |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Update
|
|
|
|
|
func (fm *FeatureManager) update() { |
|
|
|
|
enabled := make(map[string]bool) |
|
|
|
|
for _, flag := range fm.flags { |
|
|
|
|
val := fm.evaluate(flag) |
|
|
|
|
// if grafana cannot run the feature, omit metrics around it
|
|
|
|
|
if !fm.meetsRequirements(flag) { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Update the registry
|
|
|
|
|
track := 0.0 |
|
|
|
|
if val { |
|
|
|
|
// TODO: CEL - expression
|
|
|
|
|
if flag.Expression == "true" { |
|
|
|
|
track = 1 |
|
|
|
|
enabled[flag.Name] = true |
|
|
|
|
} |
|
|
|
|