aboutsummaryrefslogtreecommitdiff
path: root/internal/conf
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-02-22 18:58:16 +0800
committerᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-02-22 18:58:16 +0800
commit5efbde4fe92cf30799c3c9fd66251dfbc03c4d87 (patch)
treed7109bb8385ec0098996f170433e50c569f932d7 /internal/conf
parentc4a0a404735cdcfdcb805e9fed474c75110bca89 (diff)
conf: overhaul database settings
Diffstat (limited to 'internal/conf')
-rw-r--r--internal/conf/conf.go9
-rw-r--r--internal/conf/static.go25
2 files changed, 34 insertions, 0 deletions
diff --git a/internal/conf/conf.go b/internal/conf/conf.go
index 63df2c8e..0850962e 100644
--- a/internal/conf/conf.go
+++ b/internal/conf/conf.go
@@ -182,6 +182,15 @@ func Init(customConf string) error {
Repository.Root = ensureAbs(Repository.Root)
Repository.Upload.TempPath = ensureAbs(Repository.Upload.TempPath)
+ // *******************************
+ // ----- Database settings -----
+ // *******************************
+
+ if err = File.Section("database").MapTo(&Database); err != nil {
+ return errors.Wrap(err, "mapping [database] section")
+ }
+ Database.Path = ensureAbs(Database.Path)
+
handleDeprecated()
// TODO
diff --git a/internal/conf/static.go b/internal/conf/static.go
index c9fff1dc..80857f3a 100644
--- a/internal/conf/static.go
+++ b/internal/conf/static.go
@@ -123,6 +123,22 @@ var (
MaxFiles int
} `ini:"repository.upload"`
}
+
+ // Database settings
+ Database struct {
+ Type string
+ Host string
+ Name string
+ User string
+ Password string
+ SSLMode string `ini:"SSL_MODE"`
+ Path string
+
+ // Deprecated: Use Type instead, will be removed in 0.13.
+ DbType string
+ // Deprecated: Use Password instead, will be removed in 0.13.
+ Passwd string
+ }
)
// handleDeprecated transfers deprecated values to the new ones when set.
@@ -140,4 +156,13 @@ func handleDeprecated() {
Server.LandingURL = "/explore"
Server.LangdingPage = ""
}
+
+ if Database.DbType != "" {
+ Database.Type = Database.DbType
+ Database.DbType = ""
+ }
+ if Database.Passwd != "" {
+ Database.Password = Database.Passwd
+ Database.Passwd = ""
+ }
}