-
Notifications
You must be signed in to change notification settings - Fork 4.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
support env var expansion in envoy statsd urls #8564
support env var expansion in envoy statsd urls #8564
Conversation
|
||
if !allowedStatsSinkEnvVars[s] { | ||
// if the specified env var isn't explicitly allowed, unexpand it | ||
return fmt.Sprintf("${%s}", s) |
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.
Could also just return an empty string. no strong preference here; either way, if someone enters a disallowed env var, it's going to fail url.Parse
, so the result here is just cosmetic.
@@ -305,6 +307,18 @@ func (c *BootstrapConfig) generateStatsSinkJSON(name string, addr string) (strin | |||
}`, nil | |||
} | |||
|
|||
func (c *BootstrapConfig) statsSinkEnvMapping(s string) string { | |||
allowedStatsSinkEnvVars := map[string]bool{ |
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.
this seemed like the simplest place to put this allowlist. happy to move elsewhere if desired.
the original implementation explicitly didn't support expanding arbitrary env vars, so the purpose here to minimize the potential side effects while still providing the ability to dynamically set this. happy to allow additional env vars or remove this functionality entirely in favor of os.ExpandEnv
if that's preferable.
@mkeeler @i0rek what's the best way to get this change reviewed? |
@dnephin @s-christoff what's the best way to get this change reviewed? |
@mkcp what's the best way to get this change reviewed? |
e677545
to
ea33c39
Compare
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.
Thank you for the PR! Sorry it took us a while to review it.
I think this looks good! I rebased the PR to resolve some conflicts, updated the test expected value because it had changed due to other changes, and also added a changelog entry.
If the tests still pass I think we are good to merge.
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/340396. |
Fixes #8561