mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-24 22:06:43 +01:00
refactor(config): add field dialect
This commit is contained in:
parent
31a71abf4a
commit
0b3b56620c
@ -50,22 +50,24 @@ func Execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runService() {
|
func runService() {
|
||||||
switch {
|
store := createStore()
|
||||||
case util.Config.MySQL.IsPresent():
|
defer store.Close()
|
||||||
|
|
||||||
|
dialect, err := util.Config.GetDialect()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
switch dialect {
|
||||||
|
case util.DbDriverMySQL:
|
||||||
fmt.Printf("MySQL %v@%v %v\n", util.Config.MySQL.Username, util.Config.MySQL.Hostname, util.Config.MySQL.DbName)
|
fmt.Printf("MySQL %v@%v %v\n", util.Config.MySQL.Username, util.Config.MySQL.Hostname, util.Config.MySQL.DbName)
|
||||||
case util.Config.BoltDb.IsPresent():
|
case util.DbDriverBolt:
|
||||||
fmt.Printf("BoltDB %v\n", util.Config.BoltDb.Hostname)
|
fmt.Printf("BoltDB %v\n", util.Config.BoltDb.Hostname)
|
||||||
case util.Config.Postgres.IsPresent():
|
case util.DbDriverPostgres:
|
||||||
fmt.Printf("Postgres %v@%v %v\n", util.Config.Postgres.Username, util.Config.Postgres.Hostname, util.Config.Postgres.DbName)
|
fmt.Printf("Postgres %v@%v %v\n", util.Config.Postgres.Username, util.Config.Postgres.Hostname, util.Config.Postgres.DbName)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("database configuration not found"))
|
panic(fmt.Errorf("database configuration not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath)
|
fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath)
|
||||||
|
|
||||||
store := createStore()
|
|
||||||
defer store.Close()
|
|
||||||
|
|
||||||
fmt.Printf("Semaphore %v\n", util.Version)
|
fmt.Printf("Semaphore %v\n", util.Version)
|
||||||
fmt.Printf("Interface %v\n", util.Config.Interface)
|
fmt.Printf("Interface %v\n", util.Config.Interface)
|
||||||
fmt.Printf("Port %v\n", util.Config.Port)
|
fmt.Printf("Port %v\n", util.Config.Port)
|
||||||
@ -89,7 +91,7 @@ func runService() {
|
|||||||
|
|
||||||
fmt.Println("Server is running")
|
fmt.Println("Server is running")
|
||||||
|
|
||||||
err := http.ListenAndServe(util.Config.Interface+util.Config.Port, cropTrailingSlashMiddleware(router))
|
err = http.ListenAndServe(util.Config.Interface+util.Config.Port, cropTrailingSlashMiddleware(router))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
|
@ -35,7 +35,7 @@ func applyChangeUserArgsForUser(user db.User, store db.Store) {
|
|||||||
user.Name = targetUserArgs.name
|
user.Name = targetUserArgs.name
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetUserArgs.admin == true {
|
if targetUserArgs.admin {
|
||||||
user.Admin = true
|
user.Admin = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ func CreateStore() db.Store {
|
|||||||
case util.DbDriverPostgres:
|
case util.DbDriverPostgres:
|
||||||
return &sql.SqlDb{}
|
return &sql.SqlDb{}
|
||||||
default:
|
default:
|
||||||
panic("Unsupported database dialect")
|
panic("Unsupported database dialect: " + config.Dialect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,8 +276,6 @@ func (conf *ConfigType) GetDBConfig() (dbConfig DbConfig, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dbConfig.Dialect = dialect
|
|
||||||
|
|
||||||
switch dialect {
|
switch dialect {
|
||||||
case DbDriverBolt:
|
case DbDriverBolt:
|
||||||
dbConfig = conf.BoltDb
|
dbConfig = conf.BoltDb
|
||||||
@ -288,6 +286,9 @@ func (conf *ConfigType) GetDBConfig() (dbConfig DbConfig, err error) {
|
|||||||
default:
|
default:
|
||||||
err = errors.New("database configuration not found")
|
err = errors.New("database configuration not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbConfig.Dialect = dialect
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user