mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 00:42:03 +08:00

* add a migration to remove the scope from any permissions where action is alert.instances:read * linting
34 lines
993 B
Go
34 lines
993 B
Go
package accesscontrol
|
|
|
|
import (
|
|
"xorm.io/xorm"
|
|
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
|
)
|
|
|
|
const (
|
|
AlertingScopeRemovalMigrationID = "removing scope from alert.instances:read action migration"
|
|
)
|
|
|
|
func AddAlertingScopeRemovalMigration(mg *migrator.Migrator) {
|
|
mg.AddMigration(AlertingScopeRemovalMigrationID, &alertingScopeRemovalMigrator{})
|
|
}
|
|
|
|
var _ migrator.CodeMigration = new(alertingScopeRemovalMigrator)
|
|
|
|
type alertingScopeRemovalMigrator struct {
|
|
permissionMigrator
|
|
}
|
|
|
|
func (p *alertingScopeRemovalMigrator) SQL(dialect migrator.Dialect) string {
|
|
return CodeMigrationSQL
|
|
}
|
|
|
|
func (p *alertingScopeRemovalMigrator) Exec(sess *xorm.Session, migrator *migrator.Migrator) error {
|
|
p.sess = sess
|
|
p.dialect = migrator.Dialect
|
|
_, err := p.sess.Exec("UPDATE permission SET `scope` = '', `kind` = '', `attribute` = '', `identifier` = '' WHERE action = ?", accesscontrol.ActionAlertingInstanceRead)
|
|
return err
|
|
}
|