Chore: Update settings to support k8s needs (#78235)

use util.SplitString, implement DynamicSection KeysHash
This commit is contained in:
Dan Cech 2023-11-15 15:26:28 -05:00 committed by GitHub
parent f38f657f87
commit c330b7d18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1050,7 +1050,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
Target := valueAsString(iniFile.Section(""), "target", "all")
if Target != "" {
cfg.Target = strings.Split(Target, " ")
cfg.Target = util.SplitString(Target)
}
Env = valueAsString(iniFile.Section(""), "app_mode", "development")
cfg.Env = Env
@ -1409,6 +1409,18 @@ func (s *DynamicSection) Key(k string) *ini.Key {
return key
}
func (s *DynamicSection) KeysHash() map[string]string {
hash := s.section.KeysHash()
for k := range hash {
envKey := EnvKey(s.section.Name(), k)
envValue := os.Getenv(envKey)
if len(envValue) > 0 {
hash[k] = envValue
}
}
return hash
}
// SectionWithEnvOverrides dynamically overrides keys with environment variables.
// As a side effect, the value of the setting key will be updated if an environment variable is present.
func (cfg *Cfg) SectionWithEnvOverrides(s string) *DynamicSection {