From e9392584a3a7465caa418b4e70fa1ac0a4e4f9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Thu, 3 Dec 2020 14:42:13 +0100 Subject: [PATCH] Refactor: some more renames --- pkg/server/server.go | 2 +- .../librarypanels.go} | 26 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) rename pkg/services/{librarypanel/librarypanel.go => librarypanels/librarypanels.go} (68%) diff --git a/pkg/server/server.go b/pkg/server/server.go index 5bca6b9a59d..6fd28aa63e9 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -35,7 +35,7 @@ import ( _ "github.com/grafana/grafana/pkg/services/alerting" _ "github.com/grafana/grafana/pkg/services/auth" _ "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/notifications" _ "github.com/grafana/grafana/pkg/services/provisioning" diff --git a/pkg/services/librarypanel/librarypanel.go b/pkg/services/librarypanels/librarypanels.go similarity index 68% rename from pkg/services/librarypanel/librarypanel.go rename to pkg/services/librarypanels/librarypanels.go index 255ddc4e60a..d48132444e1 100644 --- a/pkg/services/librarypanel/librarypanel.go +++ b/pkg/services/librarypanels/librarypanels.go @@ -1,33 +1,31 @@ -package librarypanel +package librarypanels import ( "github.com/grafana/grafana/pkg/infra/log" "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/setting" ) -// LibraryPanel is the service the Panel Library feature. -type LibraryPanel struct { - Cfg *setting.Cfg `inject:""` - SQLStore *sqlstore.SQLStore `inject:""` - log log.Logger +// LibraryPanelService is the service for the Panel Library feature. +type LibraryPanelService struct { + Cfg *setting.Cfg `inject:""` + log log.Logger } func init() { - registry.RegisterService(&LibraryPanel{}) + registry.RegisterService(&LibraryPanelService{}) } // Init initializes the LibraryPanel service -func (pl *LibraryPanel) Init() error { +func (pl *LibraryPanelService) Init() error { pl.log = log.New("library_panel") return nil } -// IsEnabled returns true if the LibraryPanel service is enabled for this instance. -func (pl *LibraryPanel) IsEnabled() bool { +// IsEnabled returns true if the Panel Library feature is enabled for this instance. +func (pl *LibraryPanelService) IsEnabled() bool { if pl.Cfg == nil { return false } @@ -37,12 +35,12 @@ func (pl *LibraryPanel) IsEnabled() bool { // AddMigration defines database migrations. // 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() { return } - library_panelV1 := migrator.Table{ + libraryPanelV1 := migrator.Table{ Name: "library_panel", Columns: []*migrator.Column{ {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)) }