Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Settings: make global config file optional #225

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/settings/global_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ fn get_global_config() -> Result<GlobalUser, failure::Error> {
let config_str = config_path
.to_str()
.expect("global config path should be a string");
s.merge(File::with_name(config_str))?;

// Eg.. `CF_ACCOUNT_AUTH_KEY=farts` would set the `account_auth_key` key
// Skip reading global config if non existent
// because envs might be provided
if config_path.exists() {
s.merge(File::with_name(config_str))?;
}

// Eg.. `CF_API_KEY=farts` would set the `account_auth_key` key
// envs are: CF_API_KEY and CF_EMAIL
s.merge(Environment::with_prefix("CF"))?;

let global_user: Result<GlobalUser, config::ConfigError> = s.try_into();
Expand Down