Skip to content

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

@NeonWizard

Description

@NeonWizard

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions