diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-13 15:21:32 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-13 15:21:32 +0200 |
commit | 7a5d329e49cc7018cbfa14d37589f51860f66cf0 (patch) | |
tree | 50be9a5eea1b2415bb541aff0c8cb33c0f47b8e4 /src/api/helpers.rs | |
parent | f82b938033f1a01a136315b5f37ecb89b78bca0c (diff) | |
download | garage-7a5d329e49cc7018cbfa14d37589f51860f66cf0.tar.gz garage-7a5d329e49cc7018cbfa14d37589f51860f66cf0.zip |
More error refactoring
Diffstat (limited to 'src/api/helpers.rs')
-rw-r--r-- | src/api/helpers.rs | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/src/api/helpers.rs b/src/api/helpers.rs index 121fbd5a..599be3f7 100644 --- a/src/api/helpers.rs +++ b/src/api/helpers.rs @@ -2,12 +2,7 @@ use hyper::{Body, Request}; use idna::domain_to_unicode; use serde::Deserialize; -use garage_util::data::*; - -use garage_model::garage::Garage; -use garage_model::key_table::Key; - -use crate::s3::error::*; +use crate::common_error::{*, CommonError as Error}; /// What kind of authorization is required to perform a given action #[derive(Debug, Clone, PartialEq, Eq)] @@ -81,28 +76,6 @@ pub fn authority_to_host(authority: &str) -> Result<String, Error> { authority.map(|h| domain_to_unicode(h).0) } -#[allow(clippy::ptr_arg)] -pub async fn resolve_bucket( - garage: &Garage, - bucket_name: &String, - api_key: &Key, -) -> Result<Uuid, Error> { - let api_key_params = api_key - .state - .as_option() - .ok_or_internal_error("Key should not be deleted at this point")?; - - if let Some(Some(bucket_id)) = api_key_params.local_aliases.get(bucket_name) { - Ok(*bucket_id) - } else { - Ok(garage - .bucket_helper() - .resolve_global_bucket_name(bucket_name) - .await? - .ok_or(Error::NoSuchBucket)?) - } -} - /// Extract the bucket name and the key name from an HTTP path and possibly a bucket provided in /// the host header of the request /// |