4 Commits

Author SHA1 Message Date
ee74c94359 add config collapse after reading in 2023-11-03 03:01:51 -07:00
e84645ccfa fix readme order 2023-11-03 02:25:19 -07:00
b2e7785e00 fix inverted negation 2023-11-03 02:24:06 -07:00
ef3350d66d add defaults to config file 2023-11-03 02:20:08 -07:00
3 changed files with 7 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# JETY
JSON, ENV, YAML, TOML
JSON, ENV, TOML, YAML
This is a package for collapsing multiple configuration stores (env+json, env+yaml, env+toml) and writing them back to a centralized config.

View File

@@ -175,6 +175,7 @@ func (c *ConfigManager) ReadInConfig() error {
conf[lower] = ConfigMap{Key: k, Value: v}
}
c.mapConfig = conf
c.collapse()
return nil
}

View File

@@ -34,9 +34,13 @@ func (c *ConfigManager) SetDefault(key string, value any) {
lower := strings.ToLower(key)
c.defaultConfig[lower] = ConfigMap{Key: key, Value: value}
if _, ok := c.mapConfig[lower]; !ok {
if envVal, ok := c.envConfig[lower]; !ok {
if envVal, ok := c.envConfig[lower]; ok {
c.mapConfig[lower] = envVal
c.combinedConfig[lower] = envVal
} else {
c.combinedConfig[lower] = ConfigMap{Key: key, Value: value}
}
} else {
c.combinedConfig[lower] = c.mapConfig[lower]
}
}