-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Configurable command flags through environment variables #4277
Comments
Thanks for filing this @marcaurele 👍 I could imagine doing something like what Kafka does, where any config value can be provided as a prefixed environment variable, like As for a solution, I think something like this could be accomplished with Viper, but if we only used this for log level/format initially, we might be better off doing a simple check without that. |
Yes, using a prefix is also recommended, I forgot to mention it. |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
tagging myself here, as I am also looking for an option to configure command flags through environment variables, esp. @anderseknert just curious, any update or workaround? |
No update or workaround here that I'm aware of @suneelkumarch. If you'd like to work on this, that'd be much welcome :) |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
@anderseknert I'd like to work on this if that's ok. |
Of course! 👍 |
I need this feature too. Keep me updated if you need two more eyes on this! |
@fioreale if you'd want to help review / test the PR later, that'd be welcome! |
@anderseknert which would we want to take precedence if both the env var and the flag value are set? My gut tells me the flag value in the command line should take precedence, since it's more explicit and closer to the execution, but I'd like to hear other thoughts. |
This is what I would expect, as you could have env variables set in a container for example, but for specific execution you want to be able to override them with flags. |
Agreed! |
Wrapping up this branch for a PR - I have to get approval at work, ensuring that this doesn't violate any OS contribution restrictions. In the mean time, just a heads up on the approach I took. There's a new internal package in the
I added this to the |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue. |
What part of OPA would you like to see improved?
I would like to avoid having to overwrite the container command line to customize the execution for an environment. For example, I would like to simply switch the logging level based on an environment variable, instead of editing the command line with
--log-level debug
.Describe the ideal solution
The idea would be to expose all command flags as environment variables so that by setting any of them to a value, it would have the same effect as specifying a custom flag for the container execution. Maybe there is a generic solution that can be applied to all of them at once, which would be ideal to turn all flags to corresponding environment variables.
Describe a "Good Enough" solution
The most important command is
run
to address as it's the one used for execution. Looking at the list of flags, I would say that--log-level
and--log-format
are 2 important ones to start with, as well as the one for the config file--config-file
. The change can be incremental and add flags to environment variable mapping based on perceived importance of them.Additional Context
It is not possible to build a container image by providing an argument in
CMD
1 that will be interpolate based on an environment variable. The workaround is to go throughsh
which is not available in the image (and should not).For example this won't work:
resulting in (Docker tries to access
/bin//sh
to interpolate the variable itself):Footnotes
https://docs.docker.com/engine/reference/builder/#cmd ↩
The text was updated successfully, but these errors were encountered: