Skip to content

Commit

Permalink
fix: metastore argument validation (#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
tychoish authored Jun 4, 2024
1 parent 84ef478 commit f05559b
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions crates/cli/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,24 +288,39 @@ impl ComputeServerBuilder {
}
};

let metastore_storage_conf =
match (self.metastore_bucket.clone(), self.data_dir.clone()) {
(Some(_), Some(_)) => {
return Err(anyhow!(
"cannot specify local datadir and remote metastore bucket"
))
}
(Some(bucket), None) => StorageConfig::Gcs {
bucket: Some(bucket),
service_account_key: self.service_account_path.clone().unwrap_or_default(),
},
(None, Some(p)) => {
let p = p.join("__metastore");
ensure_dir(&p)?;
StorageConfig::Local { path: p }
}
(None, None) => StorageConfig::Memory,
};
let metastore_storage_conf = match (
self.metastore_bucket.clone(),
self.data_dir.clone(),
self.service_account_path.clone(),
) {
(None, Some(_), Some(_))
| (Some(_), Some(_), None)
| (Some(_), Some(_), Some(_)) => {
return Err(anyhow!(
"cannot specify local metastore datadir with service_account_path or bucket"
))
}
(Some(_), None, None) => {
return Err(anyhow!(
"cannot specify bucket without specifying the service_account_path"
))
}
(None, None, Some(_)) => {
return Err(anyhow!(
"cannot specify service_account_path without specifying the bucket"
))
}
(Some(bucket), None, Some(service_account_path)) => StorageConfig::Gcs {
bucket: Some(bucket),
service_account_key: std::fs::read_to_string(service_account_path)?,
},
(None, Some(p), None) => {
let p = p.join("__metastore");
ensure_dir(&p)?;
StorageConfig::Local { path: p }
}
(None, None, None) => StorageConfig::Memory,
};


let metastore_client =
Expand Down

0 comments on commit f05559b

Please sign in to comment.