aboutsummaryrefslogtreecommitdiff
path: root/src/conf/conf.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf/conf.go')
-rw-r--r--src/conf/conf.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/conf/conf.go b/src/conf/conf.go
index 7a6dcbf..62ffb57 100644
--- a/src/conf/conf.go
+++ b/src/conf/conf.go
@@ -1,6 +1,7 @@
package conf
import (
+ "fmt"
"log"
"os"
@@ -18,7 +19,11 @@ type (
Db struct {
Adapter string `toml:"adapter"`
User string `toml:"user"`
- Password string `toml:"pass"`
+ Secret string `toml:"secret"`
+ Hostname string `toml:"hostname"`
+ Port string `toml:"port"`
+ DbName string `toml:"dbname"`
+ Url string
}
Server struct {
@@ -43,7 +48,9 @@ func NewConf() *Conf {
c := Conf{
cwd,
filepath,
- Db{},
+ Db{
+ Hostname: "localhost",
+ },
Server{
UiPath: cwd + "/ui",
},
@@ -52,11 +59,24 @@ func NewConf() *Conf {
if err != nil {
log.Fatalln(err)
}
+ c.setDbUrl()
log.Printf("Config loaded: %s", c)
return &c
}
+func (c *Conf) setDbUrl() {
+ c.Db.Url = fmt.Sprintf(
+ "%s://%s:%s@%s:%s/%s",
+ c.Db.Adapter,
+ c.Db.User,
+ c.Db.Secret,
+ c.Db.Hostname,
+ c.Db.Port,
+ c.Db.DbName,
+ )
+}
+
func (c *Conf) GetCwd() string {
return c.cwd
}