fix(be): returns store according configuration

This commit is contained in:
Denis Gukov 2021-06-25 02:17:50 +05:00
parent cca0e95dea
commit c9f64b51cf

View File

@ -3,11 +3,21 @@ package factory
import (
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/db/bolt"
//"github.com/ansible-semaphore/semaphore/db/sql"
"github.com/ansible-semaphore/semaphore/db/sql"
"github.com/ansible-semaphore/semaphore/util"
)
func CreateStore() db.Store {
return &bolt.BoltDb{}
//return &sql.SqlDb{}
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{}
default:
panic("Unsupported database dialect")
}
}