-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): Support shell like syntax for environment variable substitution #13229
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for putting this up, this will be a nice addition. We will obviously require a bit of testing to ensure we really do not regress anyone's config as they are today.
I would like the --env-file removed from this PR. That should be a second PR where we can discuss the reasoning and justification for another config file.
I have some initial comments and observations.
Thanks!
08fe5fc
to
e6f05c4
Compare
228675a
to
212c59f
Compare
I'm catching up on stuff post-vacation. I will take a look at this early next week after we do v1.26.3. I want to play with it a bit more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! When using env variables with bool and numeric you get TOML validation errors, which is unfortunate, but understandable and that happens today anyway as well.
Went through and played with boolean for debug value and for hostname via string. Tried a few places to toss variables in as comments with no negative effect.
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Thanks for reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks for the cool feature @neelayu!
First, I should clarify. Telegraf does not complain about any validation errors, but my IDE will complain about invalid toml when you say |
Required for all PRs
resolves #10557
Support for shell like environment variable expansion. This PR uses a library used by docker-compose to expand variables from the environment. It was a conscious choice to use a library and not build on existing regex patterns. The library gives more flexibility and is actively maintained.
It builds on #10726 and removes the comments before it is passed on to the toml parser. Most cases are handled in the code. Let me know if I missed any. The reason to remove comments before env substitution was due to the fact the default config generated includes the text
More specifically the syntax
${}
throws an error. So for backwards compatibility, the choice was made to remove the comments. The code to remove comments handles cases where#
can be part of string values.Kindly review. Thanks