This commit is contained in:
Björn Wenzel 2025-03-29 22:38:33 +00:00 committed by GitHub
commit 887f64b6ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -223,6 +223,9 @@ The following environment variables configure the exporter:
* `DATA_SOURCE_NAME`
the default legacy format. Accepts URI form and key=value form arguments. The
URI may contain the username and password to connect with.
* `DATA_SOURCE_NAME_FILE`
The same as above but reads the URI from a file.
* `DATA_SOURCE_URI`
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname

View File

@ -124,6 +124,16 @@ func getDataSources() ([]string, error) {
return strings.Split(dsn, ","), nil
}
dataSourceNameFile := os.Getenv("DATA_SOURCE_NAME_FILE")
if len(dataSourceNameFile) != 0 {
fileContents, err := ioutil.ReadFile(dataSourceNameFile)
if err != nil {
return nil, fmt.Errorf("failed loading data source name file %s: %s", dataSourceNameFile, err.Error())
}
dsnContent := strings.TrimSpace(string(fileContents))
return strings.Split(dsnContent, ","), nil
}
var user, pass, uri string
dataSourceUserFile := os.Getenv("DATA_SOURCE_USER_FILE")