summaryrefslogtreecommitdiffstats
path: root/config/allconfig/load.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/allconfig/load.go')
-rw-r--r--config/allconfig/load.go55
1 files changed, 33 insertions, 22 deletions
diff --git a/config/allconfig/load.go b/config/allconfig/load.go
index 2d9185f6f..4fb8bbaef 100644
--- a/config/allconfig/load.go
+++ b/config/allconfig/load.go
@@ -233,40 +233,51 @@ func (l configLoader) applyOsEnvOverrides(environ []string) error {
if existing != nil {
val, err := metadecoders.Default.UnmarshalStringTo(env.Value, existing)
- if err != nil {
+ if err == nil {
+ val = l.envValToVal(env.Key, val)
+ if owner != nil {
+ owner[nestedKey] = val
+ } else {
+ l.cfg.Set(env.Key, val)
+ }
continue
}
+ }
- if owner != nil {
- owner[nestedKey] = val
- } else {
- l.cfg.Set(env.Key, val)
- }
+ if owner != nil && nestedKey != "" {
+ owner[nestedKey] = env.Value
} else {
- if nestedKey != "" {
- owner[nestedKey] = env.Value
- } else {
- var val any
- key := strings.ReplaceAll(env.Key, delim, ".")
- _, ok := allDecoderSetups[key]
- if ok {
- // A map.
- if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]any{}); err == nil {
- val = v
- }
+ var val any
+ key := strings.ReplaceAll(env.Key, delim, ".")
+ _, ok := allDecoderSetups[key]
+ if ok {
+ // A map.
+ if v, err := metadecoders.Default.UnmarshalStringTo(env.Value, map[string]any{}); err == nil {
+ val = v
}
- if val == nil {
- // A string.
- val = l.envStringToVal(key, env.Value)
- }
- l.cfg.Set(key, val)
}
+
+ if val == nil {
+ // A string.
+ val = l.envStringToVal(key, env.Value)
+ }
+ l.cfg.Set(key, val)
}
+
}
return nil
}
+func (l *configLoader) envValToVal(k string, v any) any {
+ switch v := v.(type) {
+ case string:
+ return l.envStringToVal(k, v)
+ default:
+ return v
+ }
+}
+
func (l *configLoader) envStringToVal(k, v string) any {
switch k {
case "disablekinds", "disablelanguages":