2020-12-01 20:06:49 +01:00
|
|
|
package factory
|
|
|
|
|
|
|
|
import (
|
2024-10-26 14:56:17 +02:00
|
|
|
"github.com/semaphoreui/semaphore/db"
|
|
|
|
"github.com/semaphoreui/semaphore/db/bolt"
|
|
|
|
"github.com/semaphoreui/semaphore/db/sql"
|
|
|
|
"github.com/semaphoreui/semaphore/util"
|
2020-12-01 20:06:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func CreateStore() db.Store {
|
2021-06-24 23:17:50 +02:00
|
|
|
config, err := util.Config.GetDBConfig()
|
|
|
|
if err != nil {
|
|
|
|
panic("Can not read configuration")
|
|
|
|
}
|
|
|
|
switch config.Dialect {
|
|
|
|
case util.DbDriverMySQL:
|
|
|
|
return &sql.SqlDb{}
|
|
|
|
case util.DbDriverBolt:
|
|
|
|
return &bolt.BoltDb{}
|
2021-08-24 12:51:21 +02:00
|
|
|
case util.DbDriverPostgres:
|
|
|
|
return &sql.SqlDb{}
|
2021-06-24 23:17:50 +02:00
|
|
|
default:
|
2021-08-28 18:24:54 +02:00
|
|
|
panic("Unsupported database dialect: " + config.Dialect)
|
2021-06-24 23:17:50 +02:00
|
|
|
}
|
2020-12-01 20:06:49 +01:00
|
|
|
}
|