Configuration: Fix env var override of sections containing hyphen (#25178)

Fixes so that ini-sections containing hyphen is replaced with
underscore. Fixes an issue with backend plugin settings.

Ref grafana/grafana-image-renderer#147

(cherry picked from commit 34d5ffa562)
This commit is contained in:
Marcus Efraimsson
2020-06-03 17:19:31 +02:00
committed by Marcus Andersson
parent 9bc12846a2
commit ec2e951cd3
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -373,6 +373,7 @@ func applyEnvVariableOverrides(file *ini.File) error {
func envKey(sectionName string, keyName string) string {
sN := strings.ToUpper(strings.Replace(sectionName, ".", "_", -1))
sN = strings.Replace(sN, "-", "_", -1)
kN := strings.ToUpper(strings.Replace(keyName, ".", "_", -1))
envKey := fmt.Sprintf("GF_%s_%s", sN, kN)
return envKey