mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
FeatureFlags: fix setting flags to false in startup (#80836)
This commit is contained in:
parent
9e08c88a1c
commit
96fe605d95
@ -102,7 +102,8 @@ func (fm *FeatureManager) update() {
|
||||
// Update the registry
|
||||
track := 0.0
|
||||
|
||||
if flag.Expression == "true" || (fm.startup[flag.Name]) {
|
||||
startup, ok := fm.startup[flag.Name]
|
||||
if startup || (!ok && flag.Expression == "true") {
|
||||
track = 1
|
||||
enabled[flag.Name] = true
|
||||
}
|
||||
|
@ -75,4 +75,25 @@ func TestFeatureManager(t *testing.T) {
|
||||
require.Equal(t, "second", flag.Description)
|
||||
require.Equal(t, "http://something", flag.DocsURL)
|
||||
})
|
||||
|
||||
t.Run("check startup false flags", func(t *testing.T) {
|
||||
ft := FeatureManager{
|
||||
flags: map[string]*FeatureFlag{},
|
||||
startup: map[string]bool{
|
||||
"a": true,
|
||||
"b": false, // but default true
|
||||
},
|
||||
}
|
||||
ft.registerFlags(FeatureFlag{
|
||||
Name: "a",
|
||||
}, FeatureFlag{
|
||||
Name: "b",
|
||||
Expression: "true",
|
||||
}, FeatureFlag{
|
||||
Name: "c",
|
||||
})
|
||||
require.True(t, ft.IsEnabledGlobally("a"))
|
||||
require.False(t, ft.IsEnabledGlobally("b"))
|
||||
require.False(t, ft.IsEnabledGlobally("c"))
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user