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

Default variables for env vars in config #354

Open
gusinacio opened this issue Oct 8, 2024 · 4 comments
Open

Default variables for env vars in config #354

gusinacio opened this issue Oct 8, 2024 · 4 comments
Labels
config meta:good-first-issue Good for newcomers p3 Low priority repo:indexer-rs type:feature New or enhanced functionality

Comments

@gusinacio
Copy link
Member

Some deployment scripts might want to have default values in case their users don't provide an environment variable. We need to update our config environment replacer to check for environment variables and use the default value if none is provided.

For a future PR: we should ignore default variables or let the user know that we don't support it.

Originally posted by @gusinacio in #344 (comment)

@gusinacio gusinacio added p3 Low priority type:feature New or enhanced functionality meta:good-first-issue Good for newcomers labels Oct 8, 2024
@gusinacio gusinacio changed the title [Feat-req]: default variables for env vars in config [Feat.Req]: default variables for env vars in config Oct 8, 2024
@taslimmuhammed
Copy link
Contributor

Hi, small doubt, .merge(Env::prefixed(prefix.get_prefix()).split("__")) it should be overriding previous default values read from default_config.toml right?

@gusinacio
Copy link
Member Author

Yes, this Env step is the last one, it should overwrite all other steps.

Priority (higher to lower):

  • Prefixed env vars (via .merge(Env::prefixed(prefix.get_prefix()).split("__")))
  • Env vars replacing the config (envsubst)
  • Provided config (--config)
  • Default values

@taslimmuhammed
Copy link
Contributor

Sorry for making trouble again but one more doubt, so what am i missing here, if the user does not provide any environment variables then it'll go for default values right?

@gusinacio
Copy link
Member Author

Hey, no worries, ask as many questions as you need.

What I expect is what docker-compose currently have https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#interpolation-syntax for default values.

  • Default value
    • ${VAR:-default} -> value of VAR if set and non-empty, otherwise default
    • ${VAR-default} -> value of VAR if set, otherwise default

@gusinacio gusinacio changed the title [Feat.Req]: default variables for env vars in config Default variables for env vars in config Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config meta:good-first-issue Good for newcomers p3 Low priority repo:indexer-rs type:feature New or enhanced functionality
Projects
None yet
Development

No branches or pull requests

2 participants