From 2140cd72054ac6e3a94cbe5931727159de20a97f Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 3 Jan 2022 15:06:19 +0100 Subject: [PATCH] Remove website redirects --- src/api/s3_website.rs | 18 +++++++++--------- src/garage/admin.rs | 2 +- src/model/bucket_table.rs | 12 +++--------- src/model/migrate.rs | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/api/s3_website.rs b/src/api/s3_website.rs index 1ea57577..8686b832 100644 --- a/src/api/s3_website.rs +++ b/src/api/s3_website.rs @@ -170,16 +170,16 @@ impl WebsiteConfiguration { } pub fn into_garage_website_config(self) -> Result { - if let Some(rart) = self.redirect_all_requests_to { - Ok(WebsiteConfig::RedirectAll { - hostname: rart.hostname.0, - protocol: rart - .protocol - .map(|x| x.0) - .unwrap_or_else(|| "http".to_string()), - }) + if self.redirect_all_requests_to.is_some() { + Err(Error::NotImplemented( + "S3 website redirects are not currently implemented in Garage.".into(), + )) + } else if self.routing_rules.map(|x| !x.is_empty()).unwrap_or(false) { + Err(Error::NotImplemented( + "S3 routing rules are not currently implemented in Garage.".into(), + )) } else { - Ok(WebsiteConfig::Website { + Ok(WebsiteConfig { index_document: self .index_document .map(|x| x.suffix.0) diff --git a/src/garage/admin.rs b/src/garage/admin.rs index 740114c6..9328f46e 100644 --- a/src/garage/admin.rs +++ b/src/garage/admin.rs @@ -541,7 +541,7 @@ impl AdminRpcHandler { } let website = if query.allow { - Some(WebsiteConfig::Website { + Some(WebsiteConfig { index_document: "index.html".into(), error_document: None, }) diff --git a/src/model/bucket_table.rs b/src/model/bucket_table.rs index 8dcf6913..fef29b62 100644 --- a/src/model/bucket_table.rs +++ b/src/model/bucket_table.rs @@ -43,15 +43,9 @@ pub struct BucketParams { } #[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] -pub enum WebsiteConfig { - RedirectAll { - hostname: String, - protocol: String, - }, - Website { - index_document: String, - error_document: Option, - }, +pub struct WebsiteConfig { + pub index_document: String, + pub error_document: Option, } impl BucketParams { diff --git a/src/model/migrate.rs b/src/model/migrate.rs index 6b20a01f..a5508c4d 100644 --- a/src/model/migrate.rs +++ b/src/model/migrate.rs @@ -70,7 +70,7 @@ impl Migrate { let alias_ts = aliases.get_timestamp(&new_name); let website = if *old_bucket_p.website.get() { - Some(WebsiteConfig::Website { + Some(WebsiteConfig { index_document: "index.html".into(), error_document: None, })