feat: provide configuration subset via env variables#430
Merged
burningalchemist merged 1 commit intomasterfrom Jan 15, 2024
Merged
feat: provide configuration subset via env variables#430burningalchemist merged 1 commit intomasterfrom
burningalchemist merged 1 commit intomasterfrom
Conversation
7f5c6db to
163efa2
Compare
fix: set default delimiter to semicolon
163efa2 to
d59ba0a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #186
This PR adds a feature to pass values via environment variables with
SQLEXPORTER_prefix to a subset of configuration parameters such as:The precedence (where applicable) is:
Command line parameters > Environment variables > Config fileSQLEXPORTER_TARGET_COLLECTORSlist can be passed as semicolon-separated values (e.g.a;b;c;d).Given the complexity to represent jobs via dedicated environment variables, there's an option to pass the configuration as a json/yaml object to
SQLEXPORTER_JOBS. It's unclear whether it's a good idea at all, so it's not a part of this particular PR and might be added later.In the meantime, the recent change has brought environment variable expansion, providing a way to define DSN strings as user-defined environment variables, and expand them on the app init. This should help with separating sensitive data from the rest of the config file. In the past this urged users to treat the whole
sql_exporter.ymlfile as a secret (to conform with the good security practices) or keep sensitive data visible as plaintext (ignoring security practices). This problem might be finally considered as solved.Besides, the minimal go version in
go.modto build the project is updated tov1.21.