Skip to content

Commit

Permalink
Merge pull request #11 from stackrox/feature/config-environment
Browse files Browse the repository at this point in the history
Make it easier to override config via env vars
  • Loading branch information
erthalion authored Nov 30, 2023
2 parents 73d8499 + f4b97f7 commit 74de174
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ fn main() {
.add_source(config::File::with_name("/etc/berserker/workload.toml").required(false))
.add_source(config::File::with_name("workload.toml").required(false))
// Add in settings from the environment (with a prefix of APP)
// Eg.. `WORKLOAD_DEBUG=1 ./target/app` would set the `debug` key
.add_source(config::Environment::with_prefix("WORKLOAD"))
// Eg.. `BERSERKER__WORKLOAD__ARRIVAL_RATE=1` would set the `arrival_rate` key
.add_source(
config::Environment::with_prefix("BERSERKER")
.try_parsing(true)
.separator("__"),
)
.build()
.unwrap()
.try_deserialize::<WorkloadConfig>()
Expand Down

0 comments on commit 74de174

Please sign in to comment.