35 lines
727 B
Go
35 lines
727 B
Go
package config
|
|
|
|
import "git.secnex.io/cluequest/go-sdk/utils"
|
|
|
|
type DatabaseConfiguration struct {
|
|
Host string
|
|
Port string
|
|
User string
|
|
Pass string
|
|
DB string
|
|
SSL string
|
|
}
|
|
|
|
func NewDatabaseConfiguration(host, port, user, password, name, ssl string) DatabaseConfiguration {
|
|
return DatabaseConfiguration{
|
|
Host: host,
|
|
Port: port,
|
|
User: user,
|
|
Pass: password,
|
|
DB: name,
|
|
SSL: ssl,
|
|
}
|
|
}
|
|
|
|
func NewDatabaseConfigurationFromEnv() DatabaseConfiguration {
|
|
return NewDatabaseConfiguration(
|
|
utils.GetEnv("DB_HOST", "localhost"),
|
|
utils.GetEnv("DB_PORT", "5432"),
|
|
utils.GetEnv("DB_USER", "postgres"),
|
|
utils.GetEnv("DB_PASS", ""),
|
|
utils.GetEnv("DB_NAME", "postgres"),
|
|
utils.GetEnv("DB_SSL", "disable"),
|
|
)
|
|
}
|