-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Is the community open to a backward compatible PR that would have getConfig()
reference env variables that could override values specified in XML or the database?
#643
Comments
getConfig()
reference env variables that could override values specified in XML or the database?getConfig()
reference env variables that could override values specified in XML or the database?
This is an interesting idea, but unfortunately environment variables cannot contain '/' so that is one issue... Underscore is the only special character allowed and that is already widely used in the config paths so I don't know of a general-purpose path separator. Another option which does not require any core code changes is to dump your overrides into any xml file in If you really want to try this I would suggest first implementing this in your own code as an extension/modification of some sort using an event observer and then if it turns out well offer a PR which implements the same directly in the core. My main concern when adding this in would be the security implications. E.g. can environment variables be trusted (e.g. overriding the API endpoint url to cause sensitive information to be sent to the wrong address)? Can users get environment variable values that they couldn't expose before (e.g. database passwords)? Using a declarative approach of mapping environment variables to paths would help a lot to prevent abuse. <config>
<global>
<environment>
<default>
<foo>
<bar>
<baz>MY_FOO_BAR_BAZ</baz>
... Or: <config>
<global>
<environment>
<MY_FOO_BAR_BAZ>default/foo/bar/baz</MY_FOO_BAR_BAZ>
... The above would be used to read the value from |
Ah, I'd seen tools such as dotenv honor slashes. I didn't realize that environments don't natively support this. I had only tested this concept with:
I think there would have to be an exception thrown if My main use-case for this is for establishing connections. For example, currently on Platform.sh (the service behind Magento Cloud) I have to keep my I think the alternative route to this is implementing something like: https://packagist.org/packages/gracious/magento-env-config |
Hi As there is a potential security risk I would say this feature should not be bundled in mage lts by default. |
My general rule of thumb for this would be: "how is Magento2 handling this?" |
Are we in agreement on how this should be handled? Env vars adhering to the M2 standard? |
I suppose the mapping could be avoided by using the M2 naming convention. So then during bootstrap the env vars could be iterated and applied using setNode for any that match the pattern. |
I'm closing this because there's no activity in 2 years. Feel free to reopen it when new ideas will arise, possibly with a PR. |
@tylers-username This was just passed as completed via #3863 |
Sorry if this has been discussed before, I did not dig through Issue history.
I'm considering opening a PR that lets you override XML and DB config values with env variables. It should be non-breaking.
For example, you may have something like:
This can be referenced today with:
With my proposed solution, you'd be able to implement an inveronment variable such as
MAGE_CONFIG/CATALOG/SOME_NESTED_NODE/HEADER="My new header"
. Magento would then convert anyMAGE_CONFIG/
variables to an XML node in order to maintain compatibility and load it last to ensure that it overrides any previously set values.The text was updated successfully, but these errors were encountered: