mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
feat: prepare for multiple database types (#4068)
BREAKING CHANGE: the database and admin user config has changed.
This commit is contained in:
@@ -9,15 +9,16 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Database database.Config
|
||||
AdminUser database.User
|
||||
Machine *id.Config
|
||||
Log *logging.Config
|
||||
Database database.Config
|
||||
Machine *id.Config
|
||||
Log *logging.Config
|
||||
}
|
||||
|
||||
func MustNewConfig(v *viper.Viper) *Config {
|
||||
config := new(Config)
|
||||
err := v.Unmarshal(config)
|
||||
err := v.Unmarshal(config,
|
||||
viper.DecodeHook(database.DecodeHook),
|
||||
)
|
||||
logging.OnError(err).Fatal("unable to read config")
|
||||
|
||||
err = config.Log.SetLogger()
|
||||
@@ -25,21 +26,3 @@ func MustNewConfig(v *viper.Viper) *Config {
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
func adminConfig(config *Config) database.Config {
|
||||
adminConfig := config.Database
|
||||
adminConfig.Username = config.AdminUser.Username
|
||||
adminConfig.Password = config.AdminUser.Password
|
||||
adminConfig.SSL.Cert = config.AdminUser.SSL.Cert
|
||||
adminConfig.SSL.Key = config.AdminUser.SSL.Key
|
||||
if config.AdminUser.SSL.RootCert != "" {
|
||||
adminConfig.SSL.RootCert = config.AdminUser.SSL.RootCert
|
||||
}
|
||||
if config.AdminUser.SSL.Mode != "" {
|
||||
adminConfig.SSL.Mode = config.AdminUser.SSL.Mode
|
||||
}
|
||||
//use default database because the zitadel database might not exist
|
||||
adminConfig.Database = ""
|
||||
|
||||
return adminConfig
|
||||
}
|
||||
|
Reference in New Issue
Block a user