mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-24 22:25:15 +00:00
feat(config): only read file sub-keys from files
This removes reading config values from _file and instead only reads from file sub keys. This should make it easier to not accidentally specify the same value twice.
The syntax via env does not change, but via a config file this:
database:
password_file: foo
becomes
database:
password:
file: foo
This commit is contained in:
@@ -440,17 +440,9 @@ func getConfigValueFromFile(configKey string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func readConfigvaluesFromFiles() {
|
||||
func readConfigValuesFromFiles() {
|
||||
keys := viper.AllKeys()
|
||||
for _, key := range keys {
|
||||
if strings.HasSuffix(key, "_file") {
|
||||
value := getConfigValueFromFile(key)
|
||||
if value != "" {
|
||||
viper.Set(strings.TrimSuffix(key, "_file"), value)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Env is evaluated manually at runtime, so we need to check this for each key
|
||||
value := getConfigValueFromFile(key + ".file")
|
||||
if value != "" {
|
||||
@@ -503,7 +495,7 @@ func InitConfig() {
|
||||
log.Info("No config file found, using default or config from environment variables.")
|
||||
}
|
||||
|
||||
readConfigvaluesFromFiles()
|
||||
readConfigValuesFromFiles()
|
||||
|
||||
if RateLimitStore.GetString() == "keyvalue" {
|
||||
RateLimitStore.Set(KeyvalueType.GetString())
|
||||
|
||||
Reference in New Issue
Block a user