Skip to content

Commit

Permalink
fix(config): parser should ignore HTSGET_CONFIG because that gets p…
Browse files Browse the repository at this point in the history
…icked up by the clap Args parser
  • Loading branch information
mmalenic committed Jan 22, 2025
1 parent 44e17f1 commit 797a2da
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions htsget-config/src/config/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@ impl Parser<'_> {
Parser::String(string) => Toml::string(string),
Parser::Path(path) => Toml::file(path),
})
.merge(Env::prefixed(ENVIRONMENT_VARIABLE_PREFIX).map(|k| {
// This has to list all possible nested values to resolve issues with ambiguity when
// deserializing. E.g. see https://github.com/SergioBenitez/Figment/issues/12
k.as_str()
.to_lowercase()
.replace("ticket_server_", "ticket_server.")
.replace("data_server_", "data_server.")
.replace("cors_", "cors.")
.replace("tls_", "tls.")
.into()
}))
.merge(
Env::prefixed(ENVIRONMENT_VARIABLE_PREFIX)
.filter(|k| k != "config")
.map(|k| {
// This has to list all possible nested values to resolve issues with ambiguity when
// deserializing. E.g. see https://github.com/SergioBenitez/Figment/issues/12
k.as_str()
.to_lowercase()
.replace("ticket_server_", "ticket_server.")
.replace("data_server_", "data_server.")
.replace("cors_", "cors.")
.replace("tls_", "tls.")
.into()
}),
)
.extract()
.map_err(|err| io::Error::new(ErrorKind::Other, format!("failed to parse config: {err}")))?;

Expand Down

0 comments on commit 797a2da

Please sign in to comment.