Documentation
¶
Index ¶
- Constants
- Variables
- func IsTestDBMSSQL() bool
- func IsTestDbMySQL() bool
- func IsTestDbPostgres() bool
- func MockTimeNow(constTime time.Time)
- func NotServiceAccountFilter(ss *SQLStore) string
- func ResetTimeNow()
- func UserDeletions() []string
- func WrapDatabaseDriverWithHooks(dbType string, tracer tracing.Tracer) string
- type ContextSessionKey
- type DBSession
- type DBTransactionFunc
- type DashboardTag
- type DatabaseConfig
- type ITestDB
- type InitTestDBOpt
- type SQLBuilder
- func (sb *SQLBuilder) AddParams(params ...interface{})
- func (sb *SQLBuilder) GetParams() []interface{}
- func (sb *SQLBuilder) GetSQLString() string
- func (sb *SQLBuilder) Write(sql string, params ...interface{})
- func (sb *SQLBuilder) WriteDashboardPermissionFilter(user *user.SignedInUser, permission models.PermissionType)
- type SQLStore
- func InitTestDB(t ITestDB, opts ...InitTestDBOpt) *SQLStore
- func InitTestDBWithMigration(t ITestDB, migration registry.DatabaseMigrator, opts ...InitTestDBOpt) *SQLStore
- func ProvideService(cfg *setting.Cfg, cacheService *localcache.CacheService, ...) (*SQLStore, error)
- func ProvideServiceForTests(migrations registry.DatabaseMigrator) (*SQLStore, error)
- func (ss *SQLStore) AddOrgUser(ctx context.Context, cmd *models.AddOrgUserCommand) error
- func (ss *SQLStore) Bus() bus.Bus
- func (ss *SQLStore) CreateOrg(ctx context.Context, cmd *models.CreateOrgCommand) error
- func (ss *SQLStore) CreateOrgWithMember(name string, userID int64) (models.Org, error)
- func (ss *SQLStore) CreateUser(ctx context.Context, cmd user.CreateUserCommand) (*user.User, error)
- func (ss *SQLStore) DeleteOrg(ctx context.Context, cmd *models.DeleteOrgCommand) error
- func (ss *SQLStore) DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error
- func (ss *SQLStore) DeleteUserInSession(ctx context.Context, sess *DBSession, cmd *models.DeleteUserCommand) error
- func (ss *SQLStore) GetAdminStats(ctx context.Context, query *models.GetAdminStatsQuery) error
- func (ss *SQLStore) GetAlertNotifiersUsageStats(ctx context.Context, query *models.GetAlertNotifierUsageStatsQuery) error
- func (ss *SQLStore) GetDBHealthQuery(ctx context.Context, query *models.GetDBHealthQuery) error
- func (ss *SQLStore) GetDBType() core.DbType
- func (ss *SQLStore) GetDataSourceAccessStats(ctx context.Context, query *models.GetDataSourceAccessStatsQuery) error
- func (ss *SQLStore) GetDataSourceStats(ctx context.Context, query *models.GetDataSourceStatsQuery) error
- func (ss *SQLStore) GetDialect() migrator.Dialect
- func (ss *SQLStore) GetGlobalQuotaByTarget(ctx context.Context, query *models.GetGlobalQuotaByTargetQuery) error
- func (ss *SQLStore) GetOrgById(ctx context.Context, query *models.GetOrgByIdQuery) error
- func (ss *SQLStore) GetOrgByName(name string) (*models.Org, error)
- func (ss *SQLStore) GetOrgByNameHandler(ctx context.Context, query *models.GetOrgByNameQuery) error
- func (ss *SQLStore) GetOrgQuotaByTarget(ctx context.Context, query *models.GetOrgQuotaByTargetQuery) error
- func (ss *SQLStore) GetOrgQuotas(ctx context.Context, query *models.GetOrgQuotasQuery) error
- func (ss *SQLStore) GetSignedInUser(ctx context.Context, query *models.GetSignedInUserQuery) error
- func (ss *SQLStore) GetSignedInUserWithCacheCtx(ctx context.Context, query *models.GetSignedInUserQuery) error
- func (ss *SQLStore) GetSqlxSession() *session.SessionDB
- func (ss *SQLStore) GetSystemStats(ctx context.Context, query *models.GetSystemStatsQuery) error
- func (ss *SQLStore) GetSystemUserCountStats(ctx context.Context, query *models.GetSystemUserCountStatsQuery) error
- func (ss *SQLStore) GetTeamsByUser(ctx context.Context, query *models.GetTeamsByUserQuery) error
- func (ss *SQLStore) GetUserById(ctx context.Context, query *models.GetUserByIdQuery) error
- func (ss *SQLStore) GetUserOrgList(ctx context.Context, query *models.GetUserOrgListQuery) error
- func (ss *SQLStore) GetUserProfile(ctx context.Context, query *models.GetUserProfileQuery) error
- func (ss *SQLStore) GetUserQuotaByTarget(ctx context.Context, query *models.GetUserQuotaByTargetQuery) error
- func (ss *SQLStore) GetUserQuotas(ctx context.Context, query *models.GetUserQuotasQuery) error
- func (ss *SQLStore) InTransaction(ctx context.Context, fn func(ctx context.Context) error) error
- func (ss *SQLStore) Migrate(isDatabaseLockingEnabled bool) error
- func (ss *SQLStore) Quote(value string) string
- func (ss *SQLStore) Reset() error
- func (ss *SQLStore) SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error
- func (ss *SQLStore) SetUsingOrg(ctx context.Context, cmd *models.SetUsingOrgCommand) error
- func (ss *SQLStore) Sync() error
- func (ss *SQLStore) UpdateOrgAddress(ctx context.Context, cmd *models.UpdateOrgAddressCommand) error
- func (ss *SQLStore) UpdateOrgQuota(ctx context.Context, cmd *models.UpdateOrgQuotaCmd) error
- func (ss *SQLStore) UpdateUserQuota(ctx context.Context, cmd *models.UpdateUserQuotaCmd) error
- func (ss *SQLStore) WithDbSession(ctx context.Context, callback DBTransactionFunc) error
- func (ss *SQLStore) WithNewDbSession(ctx context.Context, callback DBTransactionFunc) error
- func (ss *SQLStore) WithTransactionalDbSession(ctx context.Context, callback DBTransactionFunc) error
- type Store
- type XormLogger
- func (s *XormLogger) Debug(v ...interface{})
- func (s *XormLogger) Debugf(format string, v ...interface{})
- func (s *XormLogger) Error(v ...interface{})
- func (s *XormLogger) Errorf(format string, v ...interface{})
- func (s *XormLogger) Info(v ...interface{})
- func (s *XormLogger) Infof(format string, v ...interface{})
- func (s *XormLogger) IsShowSQL() bool
- func (s *XormLogger) Level() core.LogLevel
- func (s *XormLogger) SetLevel(l core.LogLevel)
- func (s *XormLogger) ShowSQL(show ...bool)
- func (s *XormLogger) Warn(v ...interface{})
- func (s *XormLogger) Warnf(format string, v ...interface{})
Constants ¶
const MainOrgName = "Main Org."
MainOrgName is the name of the main organization.
Variables ¶
var TimeNow = time.Now
TimeNow makes it possible to test usage of time
Functions ¶
func IsTestDBMSSQL ¶
func IsTestDBMSSQL() bool
func IsTestDbMySQL ¶
func IsTestDbMySQL() bool
func IsTestDbPostgres ¶
func IsTestDbPostgres() bool
func MockTimeNow ¶
func NotServiceAccountFilter ¶
func ResetTimeNow ¶
func ResetTimeNow()
func UserDeletions ¶
func UserDeletions() []string
Types ¶
type ContextSessionKey ¶
type ContextSessionKey struct{}
ContextSessionKey is used as key to save values in `context.Context`
type DBSession ¶
func (*DBSession) PublishAfterCommit ¶
func (sess *DBSession) PublishAfterCommit(msg interface{})
type DBTransactionFunc ¶
type DashboardTag ¶
type DatabaseConfig ¶
type DatabaseConfig struct { Type string Host string Name string User string Pwd string Path string SslMode string CaCertPath string ClientKeyPath string ClientCertPath string ServerCertName string ConnectionString string IsolationLevel string MaxOpenConn int MaxIdleConn int ConnMaxLifetime int CacheMode string UrlQueryParams map[string][]string SkipMigrations bool MigrationLockAttemptTimeout int }
type ITestDB ¶
type ITestDB interface { Helper() Fatalf(format string, args ...interface{}) Logf(format string, args ...interface{}) Log(args ...interface{}) }
ITestDB is an interface of arguments for testing db
type InitTestDBOpt ¶
type InitTestDBOpt struct { // EnsureDefaultOrgAndUser flags whether to ensure that default org and user exist. EnsureDefaultOrgAndUser bool FeatureFlags []string }
InitTestDBOpt contains options for InitTestDB.
type SQLBuilder ¶
type SQLBuilder struct {
// contains filtered or unexported fields
}
func NewSqlBuilder ¶
func NewSqlBuilder(cfg *setting.Cfg) SQLBuilder
func (*SQLBuilder) AddParams ¶
func (sb *SQLBuilder) AddParams(params ...interface{})
func (*SQLBuilder) GetParams ¶
func (sb *SQLBuilder) GetParams() []interface{}
func (*SQLBuilder) GetSQLString ¶
func (sb *SQLBuilder) GetSQLString() string
func (*SQLBuilder) Write ¶
func (sb *SQLBuilder) Write(sql string, params ...interface{})
func (*SQLBuilder) WriteDashboardPermissionFilter ¶
func (sb *SQLBuilder) WriteDashboardPermissionFilter(user *user.SignedInUser, permission models.PermissionType)
type SQLStore ¶
type SQLStore struct { Cfg *setting.Cfg CacheService *localcache.CacheService Dialect migrator.Dialect // contains filtered or unexported fields }
func InitTestDB ¶
func InitTestDB(t ITestDB, opts ...InitTestDBOpt) *SQLStore
InitTestDB initializes the test DB.
func InitTestDBWithMigration ¶
func InitTestDBWithMigration(t ITestDB, migration registry.DatabaseMigrator, opts ...InitTestDBOpt) *SQLStore
InitTestDBWithMigration initializes the test DB given custom migrations.
func ProvideService ¶
func ProvideService(cfg *setting.Cfg, cacheService *localcache.CacheService, migrations registry.DatabaseMigrator, bus bus.Bus, tracer tracing.Tracer) (*SQLStore, error)
func ProvideServiceForTests ¶
func ProvideServiceForTests(migrations registry.DatabaseMigrator) (*SQLStore, error)
func (*SQLStore) AddOrgUser ¶
func (*SQLStore) CreateOrgWithMember ¶
CreateOrgWithMember creates an organization with a certain name and a certain user as member.
func (*SQLStore) CreateUser ¶
deprecated method, use only for tests
func (*SQLStore) DeleteUser ¶
func (*SQLStore) DeleteUserInSession ¶
func (*SQLStore) GetAdminStats ¶
func (*SQLStore) GetAlertNotifiersUsageStats ¶
func (*SQLStore) GetDBHealthQuery ¶
GetDBHealthQuery executes a query to check the availability of the database.
func (*SQLStore) GetDataSourceAccessStats ¶
func (*SQLStore) GetDataSourceStats ¶
func (*SQLStore) GetDialect ¶
GetDialect return the dialect
func (*SQLStore) GetGlobalQuotaByTarget ¶
func (*SQLStore) GetOrgById ¶
func (*SQLStore) GetOrgByName ¶
GetOrgByName gets an organization by name.
func (*SQLStore) GetOrgByNameHandler ¶
func (*SQLStore) GetOrgQuotaByTarget ¶
func (*SQLStore) GetOrgQuotas ¶
func (*SQLStore) GetSignedInUser ¶
func (*SQLStore) GetSignedInUserWithCacheCtx ¶
func (ss *SQLStore) GetSignedInUserWithCacheCtx(ctx context.Context, query *models.GetSignedInUserQuery) error
deprecated method, use only for tests
func (*SQLStore) GetSqlxSession ¶
func (*SQLStore) GetSystemStats ¶
func (*SQLStore) GetSystemUserCountStats ¶
func (*SQLStore) GetTeamsByUser ¶
GetTeamsByUser is used by the Guardian when checking a users' permissions TODO: use team.Service after user service is split
func (*SQLStore) GetUserById ¶
func (*SQLStore) GetUserOrgList ¶
func (*SQLStore) GetUserProfile ¶
func (*SQLStore) GetUserQuotaByTarget ¶
func (*SQLStore) GetUserQuotas ¶
func (*SQLStore) InTransaction ¶
InTransaction starts a transaction and calls the fn It stores the session in the context
func (*SQLStore) Migrate ¶
Migrate performs database migrations. Has to be done in a second phase (after initialization), since other services can register migrations during the initialization phase.
func (*SQLStore) Reset ¶
Reset resets database state. If default org and user creation is enabled, it will be ensured they exist in the database.
func (*SQLStore) SearchOrgs ¶
func (*SQLStore) SetUsingOrg ¶
deprecated method, use only for tests
func (*SQLStore) UpdateOrgAddress ¶
func (*SQLStore) UpdateOrgQuota ¶
func (*SQLStore) UpdateUserQuota ¶
func (*SQLStore) WithDbSession ¶
func (ss *SQLStore) WithDbSession(ctx context.Context, callback DBTransactionFunc) error
WithDbSession calls the callback with the session in the context (if exists). Otherwise it creates a new one that is closed upon completion. A session is stored in the context if sqlstore.InTransaction() has been been previously called with the same context (and it's not committed/rolledback yet).
func (*SQLStore) WithNewDbSession ¶
func (ss *SQLStore) WithNewDbSession(ctx context.Context, callback DBTransactionFunc) error
WithNewDbSession calls the callback with a new session that is closed upon completion.
func (*SQLStore) WithTransactionalDbSession ¶
func (ss *SQLStore) WithTransactionalDbSession(ctx context.Context, callback DBTransactionFunc) error
WithTransactionalDbSession calls the callback with a session within a transaction.
type Store ¶
type Store interface { GetAdminStats(ctx context.Context, query *models.GetAdminStatsQuery) error GetAlertNotifiersUsageStats(ctx context.Context, query *models.GetAlertNotifierUsageStatsQuery) error GetDataSourceStats(ctx context.Context, query *models.GetDataSourceStatsQuery) error GetDataSourceAccessStats(ctx context.Context, query *models.GetDataSourceAccessStatsQuery) error GetDialect() migrator.Dialect GetDBType() core.DbType GetSystemStats(ctx context.Context, query *models.GetSystemStatsQuery) error GetOrgByName(name string) (*models.Org, error) GetOrgById(context.Context, *models.GetOrgByIdQuery) error GetOrgByNameHandler(ctx context.Context, query *models.GetOrgByNameQuery) error CreateUser(ctx context.Context, cmd user.CreateUserCommand) (*user.User, error) GetUserProfile(ctx context.Context, query *models.GetUserProfileQuery) error GetSignedInUser(ctx context.Context, query *models.GetSignedInUserQuery) error WithDbSession(ctx context.Context, callback DBTransactionFunc) error WithNewDbSession(ctx context.Context, callback DBTransactionFunc) error GetOrgQuotaByTarget(ctx context.Context, query *models.GetOrgQuotaByTargetQuery) error GetOrgQuotas(ctx context.Context, query *models.GetOrgQuotasQuery) error UpdateOrgQuota(ctx context.Context, cmd *models.UpdateOrgQuotaCmd) error GetUserQuotaByTarget(ctx context.Context, query *models.GetUserQuotaByTargetQuery) error GetUserQuotas(ctx context.Context, query *models.GetUserQuotasQuery) error UpdateUserQuota(ctx context.Context, cmd *models.UpdateUserQuotaCmd) error GetGlobalQuotaByTarget(ctx context.Context, query *models.GetGlobalQuotaByTargetQuery) error WithTransactionalDbSession(ctx context.Context, callback DBTransactionFunc) error InTransaction(ctx context.Context, fn func(ctx context.Context) error) error Migrate(bool) error Sync() error Reset() error Quote(value string) string GetDBHealthQuery(ctx context.Context, query *models.GetDBHealthQuery) error SearchOrgs(ctx context.Context, query *models.SearchOrgsQuery) error GetSqlxSession() *session.SessionDB }
type XormLogger ¶
type XormLogger struct {
// contains filtered or unexported fields
}
func NewXormLogger ¶
func NewXormLogger(level glog.Lvl, grafanaLog glog.Logger) *XormLogger
func (*XormLogger) Debug ¶
func (s *XormLogger) Debug(v ...interface{})
Debug implement core.ILogger
func (*XormLogger) Debugf ¶
func (s *XormLogger) Debugf(format string, v ...interface{})
Debugf implement core.ILogger
func (*XormLogger) Error ¶
func (s *XormLogger) Error(v ...interface{})
Error implement core.ILogger
func (*XormLogger) Errorf ¶
func (s *XormLogger) Errorf(format string, v ...interface{})
Errorf implement core.ILogger
func (*XormLogger) Infof ¶
func (s *XormLogger) Infof(format string, v ...interface{})
Infof implement core.ILogger
func (*XormLogger) IsShowSQL ¶
func (s *XormLogger) IsShowSQL() bool
IsShowSQL implement core.ILogger
func (*XormLogger) SetLevel ¶
func (s *XormLogger) SetLevel(l core.LogLevel)
SetLevel implement core.ILogger
func (*XormLogger) ShowSQL ¶
func (s *XormLogger) ShowSQL(show ...bool)
ShowSQL implement core.ILogger
func (*XormLogger) Warnf ¶
func (s *XormLogger) Warnf(format string, v ...interface{})
Warnf implement core.ILogger
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package searchstore converts search queries to SQL.
|
Package searchstore converts search queries to SQL. |