From c9f64b51cf92b972e0da40f9989cde5d90e419d9 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Fri, 25 Jun 2021 02:17:50 +0500 Subject: [PATCH] fix(be): returns store according configuration --- db/factory/store.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/db/factory/store.go b/db/factory/store.go index 9bff3ba0..91ec9044 100644 --- a/db/factory/store.go +++ b/db/factory/store.go @@ -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") + } }