admin api: fix panic on GetKeyInfo with no args
This commit is contained in:
parent
4f0b923c4f
commit
1c03941b19
1 changed files with 13 additions and 9 deletions
|
@ -43,15 +43,19 @@ impl EndpointHandler for GetKeyInfoRequest {
|
|||
type Response = GetKeyInfoResponse;
|
||||
|
||||
async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> {
|
||||
let key = if let Some(id) = self.id {
|
||||
garage.key_helper().get_existing_key(&id).await?
|
||||
} else if let Some(search) = self.search {
|
||||
let key = match (self.id, self.search) {
|
||||
(Some(id), None) => garage.key_helper().get_existing_key(&id).await?,
|
||||
(None, Some(search)) => {
|
||||
garage
|
||||
.key_helper()
|
||||
.get_existing_matching_key(&search)
|
||||
.await?
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
_ => {
|
||||
return Err(Error::bad_request(
|
||||
"Either id or search must be provided (but not both)",
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
Ok(key_info_results(garage, key, self.show_secret_key).await?)
|
||||
|
|
Loading…
Add table
Reference in a new issue