Refactor: some more renames

This commit is contained in:
Hugo Häggmark
2020-12-03 14:42:13 +01:00
parent 33e3d0fda4
commit e9392584a3
2 changed files with 13 additions and 15 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ import (
_ "github.com/grafana/grafana/pkg/services/alerting" _ "github.com/grafana/grafana/pkg/services/alerting"
_ "github.com/grafana/grafana/pkg/services/auth" _ "github.com/grafana/grafana/pkg/services/auth"
_ "github.com/grafana/grafana/pkg/services/cleanup" _ "github.com/grafana/grafana/pkg/services/cleanup"
_ "github.com/grafana/grafana/pkg/services/librarypanel" _ "github.com/grafana/grafana/pkg/services/librarypanels"
_ "github.com/grafana/grafana/pkg/services/ngalert" _ "github.com/grafana/grafana/pkg/services/ngalert"
_ "github.com/grafana/grafana/pkg/services/notifications" _ "github.com/grafana/grafana/pkg/services/notifications"
_ "github.com/grafana/grafana/pkg/services/provisioning" _ "github.com/grafana/grafana/pkg/services/provisioning"
@@ -1,33 +1,31 @@
package librarypanel package librarypanels
import ( import (
"github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/registry" "github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator" "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
) )
// LibraryPanel is the service the Panel Library feature. // LibraryPanelService is the service for the Panel Library feature.
type LibraryPanel struct { type LibraryPanelService struct {
Cfg *setting.Cfg `inject:""` Cfg *setting.Cfg `inject:""`
SQLStore *sqlstore.SQLStore `inject:""` log log.Logger
log log.Logger
} }
func init() { func init() {
registry.RegisterService(&LibraryPanel{}) registry.RegisterService(&LibraryPanelService{})
} }
// Init initializes the LibraryPanel service // Init initializes the LibraryPanel service
func (pl *LibraryPanel) Init() error { func (pl *LibraryPanelService) Init() error {
pl.log = log.New("library_panel") pl.log = log.New("library_panel")
return nil return nil
} }
// IsEnabled returns true if the LibraryPanel service is enabled for this instance. // IsEnabled returns true if the Panel Library feature is enabled for this instance.
func (pl *LibraryPanel) IsEnabled() bool { func (pl *LibraryPanelService) IsEnabled() bool {
if pl.Cfg == nil { if pl.Cfg == nil {
return false return false
} }
@@ -37,12 +35,12 @@ func (pl *LibraryPanel) IsEnabled() bool {
// AddMigration defines database migrations. // AddMigration defines database migrations.
// If Panel Library is not enabled does nothing. // If Panel Library is not enabled does nothing.
func (pl *LibraryPanel) AddMigration(mg *migrator.Migrator) { func (pl *LibraryPanelService) AddMigration(mg *migrator.Migrator) {
if !pl.IsEnabled() { if !pl.IsEnabled() {
return return
} }
library_panelV1 := migrator.Table{ libraryPanelV1 := migrator.Table{
Name: "library_panel", Name: "library_panel",
Columns: []*migrator.Column{ Columns: []*migrator.Column{
{Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, {Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
@@ -57,5 +55,5 @@ func (pl *LibraryPanel) AddMigration(mg *migrator.Migrator) {
}, },
} }
mg.AddMigration("create library_panel table v1", migrator.NewAddTableMigration(library_panelV1)) mg.AddMigration("create library_panel table v1", migrator.NewAddTableMigration(libraryPanelV1))
} }