Fix nil logger in SqlStore (#54726)

This commit is contained in:
George Robinson 2022-09-05 18:24:19 +01:00 committed by GitHub
parent d5d7e920a0
commit c4d32dd687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -52,7 +52,7 @@ func (dc *CacheServiceImpl) GetDatasource(
dc.logger.Debug("Querying for data source via SQL store", "id", datasourceID, "orgId", user.OrgID)
query := &datasources.GetDataSourceQuery{Id: datasourceID, OrgId: user.OrgID}
ss := SqlStore{db: dc.SQLStore}
ss := SqlStore{db: dc.SQLStore, logger: dc.logger}
err := ss.GetDataSource(ctx, query)
if err != nil {
return nil, err
@ -92,7 +92,7 @@ func (dc *CacheServiceImpl) GetDatasourceByUID(
dc.logger.Debug("Querying for data source via SQL store", "uid", datasourceUID, "orgId", user.OrgID)
query := &datasources.GetDataSourceQuery{Uid: datasourceUID, OrgId: user.OrgID}
ss := SqlStore{db: dc.SQLStore}
ss := SqlStore{db: dc.SQLStore, logger: dc.logger}
err := ss.GetDataSource(ctx, query)
if err != nil {
return nil, err

View File

@ -36,8 +36,8 @@ type SqlStore struct {
logger log.Logger
}
func CreateStore(db sqlstore.Store) *SqlStore {
return &SqlStore{db: db}
func CreateStore(db sqlstore.Store, logger log.Logger) *SqlStore {
return &SqlStore{db: db, logger: logger}
}
// GetDataSource adds a datasource to the query model by querying by org_id as well as

View File

@ -38,7 +38,7 @@ func TestMigrate(t *testing.T) {
secretsService := secretsmng.SetupTestService(t, fakes.NewFakeSecretsStore())
secretsStore := secretskvs.NewSQLSecretsKVStore(sqlStore, secretsService, log.New("test.logger"))
migService := SetupTestDataSourceSecretMigrationService(t, sqlStore, kvStore, secretsStore, false)
ds := dsservice.CreateStore(sqlStore)
ds := dsservice.CreateStore(sqlStore, log.NewNopLogger())
dataSourceName := "Test"
dataSourceOrg := int64(1)
err := ds.AddDataSource(context.Background(), &datasources.AddDataSourceCommand{
@ -102,7 +102,7 @@ func TestMigrate(t *testing.T) {
secretsService := secretsmng.SetupTestService(t, fakes.NewFakeSecretsStore())
secretsStore := secretskvs.NewSQLSecretsKVStore(sqlStore, secretsService, log.New("test.logger"))
migService := SetupTestDataSourceSecretMigrationService(t, sqlStore, kvStore, secretsStore, true)
ds := dsservice.CreateStore(sqlStore)
ds := dsservice.CreateStore(sqlStore, log.NewNopLogger())
dataSourceName := "Test"
dataSourceOrg := int64(1)
@ -169,7 +169,7 @@ func TestMigrate(t *testing.T) {
secretsService := secretsmng.SetupTestService(t, fakes.NewFakeSecretsStore())
secretsStore := secretskvs.NewSQLSecretsKVStore(sqlStore, secretsService, log.New("test.logger"))
migService := SetupTestDataSourceSecretMigrationService(t, sqlStore, kvStore, secretsStore, false)
ds := dsservice.CreateStore(sqlStore)
ds := dsservice.CreateStore(sqlStore, log.NewNopLogger())
dataSourceName := "Test"
dataSourceOrg := int64(1)
@ -260,7 +260,7 @@ func TestMigrate(t *testing.T) {
secretsService := secretsmng.SetupTestService(t, fakes.NewFakeSecretsStore())
secretsStore := secretskvs.NewSQLSecretsKVStore(sqlStore, secretsService, log.New("test.logger"))
migService := SetupTestDataSourceSecretMigrationService(t, sqlStore, kvStore, secretsStore, true)
ds := dsservice.CreateStore(sqlStore)
ds := dsservice.CreateStore(sqlStore, log.NewNopLogger())
dataSourceName := "Test"
dataSourceOrg := int64(1)