From c330b7d18d52609168727fd1f2dacb5582240fca Mon Sep 17 00:00:00 2001 From: Dan Cech Date: Wed, 15 Nov 2023 15:26:28 -0500 Subject: [PATCH] Chore: Update settings to support k8s needs (#78235) use util.SplitString, implement DynamicSection KeysHash --- pkg/setting/setting.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 4dce0cc8d72..99b64ed06c8 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -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 {