mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Chore: Update settings to support k8s needs (#78235)
use util.SplitString, implement DynamicSection KeysHash
This commit is contained in:
parent
f38f657f87
commit
c330b7d18d
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user