FeatureFlags: Avoid using cfg.IsFeatureToggleEnabled (#81407)
This commit is contained in:
@@ -154,9 +154,7 @@ func TestMigrations(t *testing.T) {
|
||||
desc: "with editors can admin",
|
||||
config: &setting.Cfg{
|
||||
EditorsCanAdmin: true,
|
||||
// nolint:staticcheck
|
||||
IsFeatureToggleEnabled: func(key string) bool { return key == "accesscontrol" },
|
||||
Raw: ini.Empty(),
|
||||
Raw: ini.Empty(),
|
||||
},
|
||||
expectedRolePerms: map[string][]rawPermission{
|
||||
"managed:users:1:permissions": {{Action: "teams:read", Scope: team1Scope}},
|
||||
@@ -262,9 +260,6 @@ func setupTestDB(t *testing.T) *xorm.Engine {
|
||||
mg := migrator.NewMigrator(x, &setting.Cfg{
|
||||
Logger: log.New("acmigration.test"),
|
||||
Raw: ini.Empty(),
|
||||
IsFeatureToggleEnabled: func(key string) bool {
|
||||
return true
|
||||
},
|
||||
})
|
||||
migrations := &migrations.OSSMigrations{}
|
||||
migrations.AddMigration(mg)
|
||||
|
||||
@@ -21,13 +21,14 @@ import (
|
||||
// specifically added
|
||||
|
||||
type OSSMigrations struct {
|
||||
features featuremgmt.FeatureToggles
|
||||
}
|
||||
|
||||
func ProvideOSSMigrations() *OSSMigrations {
|
||||
return &OSSMigrations{}
|
||||
func ProvideOSSMigrations(features featuremgmt.FeatureToggles) *OSSMigrations {
|
||||
return &OSSMigrations{features}
|
||||
}
|
||||
|
||||
func (*OSSMigrations) AddMigration(mg *Migrator) {
|
||||
func (oss *OSSMigrations) AddMigration(mg *Migrator) {
|
||||
mg.AddCreateMigration()
|
||||
addUserMigrations(mg)
|
||||
addTempUserMigrations(mg)
|
||||
@@ -94,12 +95,8 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
|
||||
AddExternalAlertmanagerToDatasourceMigration(mg)
|
||||
|
||||
addFolderMigrations(mg)
|
||||
// nolint:staticcheck
|
||||
if mg.Cfg != nil && mg.Cfg.IsFeatureToggleEnabled != nil {
|
||||
// nolint:staticcheck
|
||||
if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagExternalServiceAuth) {
|
||||
oauthserver.AddMigration(mg)
|
||||
}
|
||||
if oss.features != nil && oss.features.IsEnabledGlobally(featuremgmt.FlagExternalServiceAuth) {
|
||||
oauthserver.AddMigration(mg)
|
||||
}
|
||||
|
||||
anonservice.AddMigration(mg)
|
||||
@@ -115,12 +112,8 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
|
||||
ualert.CreateOrgMigratedKVStoreEntries(mg)
|
||||
|
||||
// https://github.com/grafana/identity-access-team/issues/546: tracks removal of the feature toggle from the annotation permission migration
|
||||
// nolint:staticcheck
|
||||
if mg.Cfg != nil && mg.Cfg.IsFeatureToggleEnabled != nil {
|
||||
// nolint:staticcheck
|
||||
if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagAnnotationPermissionUpdate) {
|
||||
accesscontrol.AddManagedDashboardAnnotationActionsMigration(mg)
|
||||
}
|
||||
if oss.features != nil && oss.features.IsEnabledGlobally(featuremgmt.FlagAnnotationPermissionUpdate) {
|
||||
accesscontrol.AddManagedDashboardAnnotationActionsMigration(mg)
|
||||
}
|
||||
|
||||
addKVStoreMySQLValueTypeLongTextMigration(mg)
|
||||
|
||||
Reference in New Issue
Block a user