summaryrefslogtreecommitdiff
path: root/internal/config/state.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-12-11 13:03:15 +0000
committerLibravatar GitHub <noreply@github.com>2022-12-11 13:03:15 +0000
commitcb2b2fd8058a71826f23f60036cb0232eee113c7 (patch)
tree761e6c0acc211c8ca9e8b957cd99d1e93668eebe /internal/config/state.go
parent[docs] Caching webfinger with nginx (#1242) (diff)
downloadgotosocial-cb2b2fd8058a71826f23f60036cb0232eee113c7.tar.xz
[feature] support configuring database caches (#1246)
* update config generator to support nested structs, add cache configuration options * update envparsing test * add cache configuration to config parse tests * set cache configuration in testrig * move caches to sub-cache "gts" namespace, update envparsing, add cache config docs to example config Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/config/state.go')
-rw-r--r--internal/config/state.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/config/state.go b/internal/config/state.go
index 17fd31e2a..64d87d771 100644
--- a/internal/config/state.go
+++ b/internal/config/state.go
@@ -41,8 +41,8 @@ func NewState() *ConfigState {
viper := viper.New()
// Flag 'some-flag-name' becomes env var 'GTS_SOME_FLAG_NAME'
- viper.SetEnvPrefix("gts")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
+ viper.SetEnvPrefix("gts")
// Load appropriate named vals from env
viper.AutomaticEnv()
@@ -132,9 +132,13 @@ func (st *ConfigState) reloadToViper() {
func (st *ConfigState) reloadFromViper() {
if err := st.viper.Unmarshal(&st.config, func(c *mapstructure.DecoderConfig) {
c.TagName = "name"
- c.ZeroFields = true // empty the config struct before we marshal values into it
+
+ // empty config before marshaling
+ c.ZeroFields = true
oldhook := c.DecodeHook
+
+ // Use the TextUnmarshaler interface when decoding.
c.DecodeHook = mapstructure.ComposeDecodeHookFunc(
mapstructure.TextUnmarshallerHookFunc(),
oldhook,