2020-12-01 20:06:49 +01:00
|
|
|
package factory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ansible-semaphore/semaphore/db"
|
2021-05-13 16:33:04 +02:00
|
|
|
"github.com/ansible-semaphore/semaphore/db/bolt"
|
2021-06-24 23:17:50 +02:00
|
|
|
"github.com/ansible-semaphore/semaphore/db/sql"
|
|
|
|
"github.com/ansible-semaphore/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
|
|
|
}
|