aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorFelix Scheinost <fesc@symentis.com>2023-01-07 13:49:03 +0100
committerFelix Scheinost <fesc@symentis.com>2023-01-07 13:49:03 +0100
commit7b62fe3f0b1dcb336f153e54e72d8587292aa01b (patch)
tree63a4a64bc01c6dc80746e3410646ec82ad5f8453 /src/util
parentf2106c27336d7d03671dbbbcd1401232c2beb61f (diff)
downloadgarage-7b62fe3f0b1dcb336f153e54e72d8587292aa01b.tar.gz
garage-7b62fe3f0b1dcb336f153e54e72d8587292aa01b.zip
Error on both `rpc_secret` and `rpc_secret_file`
Diffstat (limited to 'src/util')
-rw-r--r--src/util/config.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/config.rs b/src/util/config.rs
index e1120822..5471fc41 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -34,6 +34,7 @@ pub struct Config {
pub compression_level: Option<i32>,
/// RPC secret key: 32 bytes hex encoded
+ /// Note: When using `read_config` this should never be `None`
pub rpc_secret: Option<String>,
/// Optional file where RPC secret key is read from
@@ -183,7 +184,12 @@ pub fn read_config(config_file: PathBuf) -> Result<Config, Error> {
let mut parsed_config: Config = toml::from_str(&config)?;
match (&parsed_config.rpc_secret, &parsed_config.rpc_secret_file) {
- (Some(_), _) => {}
+ (Some(_), None) => {
+ // no-op
+ }
+ (Some(_), Some(_)) => {
+ return Err("only one of `rpc_secret` and `rpc_secret_file` can be set".into())
+ }
(None, Some(rpc_secret_file_path_string)) => {
let mut rpc_secret_file = std::fs::OpenOptions::new()
.read(true)