Semaphore/db/factory/store.go

26 lines
597 B
Go
Raw Permalink Normal View History

package factory
import (
"github.com/ansible-semaphore/semaphore/db"
2021-05-13 16:33:04 +02:00
"github.com/ansible-semaphore/semaphore/db/bolt"
"github.com/ansible-semaphore/semaphore/db/sql"
"github.com/ansible-semaphore/semaphore/util"
)
func CreateStore() db.Store {
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{}
default:
2021-08-28 18:24:54 +02:00
panic("Unsupported database dialect: " + config.Dialect)
}
}