Skip to content
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

Don't use prefix when using envvar as default #85

Closed
NeonWizard opened this issue May 18, 2023 · 3 comments · Fixed by #99
Closed

Don't use prefix when using envvar as default #85

NeonWizard opened this issue May 18, 2023 · 3 comments · Fixed by #99
Milestone

Comments

@NeonWizard
Copy link

When doing something like env:"OVERRIDE_PORT,default=$DEFAULT_PORT", you would expect the default value to be the environment variable you get when running echo $DEFAULT_PORT in your terminal. However, it uses the same prefix as the field it's on. So, if OVERRIDE_PORT has a prefix of MY_PREFIX, the default that would be used would actually be MY_PREFIX_DEFAULT_PORT.

My specific use case where this is a problem is when I'm trying to deprecate old environment variables. I have a deprecated variable called FEATURE_DISABLEBUS, and I want to replace this with BUS_CONTROLLER_ENABLED. The new variable lives in a BusControllerConfig struct with a prefix of BUS_CONTROLLER. However, if I try to default to the deprecated variable, it tries to use BUS_CONTROLLER_FEATURE_DISABLEBUS.

@sethvargo sethvargo added this to the 1.0 milestone May 18, 2023
@sethvargo
Copy link
Owner

This seems like a good change for 1.0 (where we can break the API).

@NeonWizard
Copy link
Author

For the time being, are there any workarounds?

@sethvargo
Copy link
Owner

Unfortunately not at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants