-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make plugin-specific env take precedence over sys env #25128
Conversation
02c7ee3
to
f480a7a
Compare
Build Results: |
CI Results: |
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.
Change seems reasonable to me 👍
// go-plugin so always set SkipHostEnv and replicate the legacy behavior | ||
// ourselves if user opts in. | ||
if legacy, _ := strconv.ParseBool(os.Getenv(PluginUseLegacyEnvLayering)); legacy { | ||
// Env vars are layered as follows, with later entries overriding |
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.
👍
@@ -69,6 +70,115 @@ func testPluginCatalog(t *testing.T) *PluginCatalog { | |||
return pluginCatalog | |||
} | |||
|
|||
type warningCountLogger struct { |
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.
Neat pattern to test on the logs!
Thanks! |
* Make plugin-specific env take precedence over sys env * Expand the existing plugin env integration test --------- Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
* Make plugin-specific env take precedence over sys env * Expand the existing plugin env integration test --------- Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
Unless
SkipHostEnv
is set, go-plugin layersos.Environ()
over the top of any environment provided in theClientConfig
's command: https://github.com/hashicorp/go-plugin/blob/586d14f3dcef1eb42bfb7da4c7af102ec6638668/client.go#L657While it's too big of a breaking change to switch that behaviour in go-plugin, for Vault it seems pretty obvious that users would expect the env they specify for plugins to take precedence over the system env. For example, if most of Vault should use one proxy via HTTP_PROXY, but one plugin needs to use a different proxy, it should be possible to override the base setting when registering the plugin.
I've added a flag to opt out of the behaviour change though, and also implemented log warnings to help any users concerned about unexpected changes in behaviour.