-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Configuration: Support environment expansion in configuration #2837
Conversation
Inspired by cortexproject/cortex#2147 Fixes grafana#2311 Adds -config.expand-env as flag to loki and promtail.
Codecov Report
@@ Coverage Diff @@
## master #2837 +/- ##
==========================================
- Coverage 61.37% 61.28% -0.10%
==========================================
Files 179 179
Lines 14438 14447 +9
==========================================
- Hits 8862 8854 -8
- Misses 4766 4783 +17
Partials 810 810
|
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.
Doc content looks ok.
@timbyr super excited to see this, thank you! will try to get it reviewed in the next few says! |
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.
LGTM with a minor nit.
Thanks for the PR!
pkg/cfg/files.go
Outdated
@@ -36,13 +38,19 @@ func dJSON(y []byte) Source { | |||
} | |||
|
|||
// YAML returns a Source that opens the supplied `.yaml` file and loads it. | |||
func YAML(f string) Source { | |||
func YAML(f string, envSubst bool) Source { |
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.
I think either we should rename the variable to something like expandEnvVars
and/or add a comment about what envSubst
means. It would look clearer.
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.
Dam that was good.
:( I just wasted 2 days trying to figure out this wasn't working for us
|
Whoops. Sorry about that! This is a lesson for all of us about being sure to label future-state docs. |
Same here. Team collectively spent over a day trying to figure out why this wasn't working. Only found this from an issue I had opened. Would we want to update the docs to at least avoid confusion until the code is included in a release? |
Or at least indicate in the docs that it's not on any current release and requires a separate flag? |
I have informed the team of what happened and reminded everyone to be vigilant for future-state docs. Sometimes, particularly with contributed content, we miss something. I will file a PR to add a note to this one right now. |
@oddlittlebird the docs in that area are still missing any mention of |
Please file an issue for this. Merged PRs are not the right place to discuss problems such as this. |
What this PR does / why we need it:
Inspired by and partially cloned from cortexproject/cortex#2147
You can use environment variable references in the config file to set values that need to be configurable during deployment.
The replacement is case-sensitive and occurs before the YAML file is parsed.
References to undefined variables are replaced by empty strings unless you specify a default value or custom error text.
To specify a default value, use:
${VAR:default_value}
Where default_value is the value to use if the environment variable is undefined.
Which issue(s) this PR fixes:
Fixes #2311
Special notes for your reviewer:
Checklist