graphprotocol / indexer-rs

Rewrite of indexer-service in Rust with TAP payments implementation
Apache License 2.0
21 stars 19 forks source link

Default variables for env vars in config #354

Open gusinacio opened 2 weeks ago

gusinacio commented 2 weeks ago

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 https://github.com/graphprotocol/indexer-rs/pull/344#discussion_r1791840058_

taslimmuhammed commented 1 week ago

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

gusinacio commented 1 week ago

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

Priority (higher to lower):

taslimmuhammed commented 1 week ago

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 commented 1 week ago

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