aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-08-30 11:24:01 +0200
committerAlex Auvolat <alex@adnab.me>2023-08-30 11:24:01 +0200
commitf7b409f1140addd508c626b1e80f0f8de52a5639 (patch)
tree5aa26db98407793a155a159e29f911890667668a /src/api
parentabf011c2906d04200bb39d7bc82f7ed973215500 (diff)
downloadgarage-f7b409f1140addd508c626b1e80f0f8de52a5639.tar.gz
garage-f7b409f1140addd508c626b1e80f0f8de52a5639.zip
use a NaiveDate in data model, it serializes to string (iso 8601 format)
Diffstat (limited to 'src/api')
-rw-r--r--src/api/s3/lifecycle.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/api/s3/lifecycle.rs b/src/api/s3/lifecycle.rs
index 48265870..278cf26d 100644
--- a/src/api/s3/lifecycle.rs
+++ b/src/api/s3/lifecycle.rs
@@ -270,12 +270,11 @@ impl Expiration {
(Some(_), Some(_)) => Err("cannot have both <Days> and <Date> in <Expiration>"),
(None, None) => Err("<Expiration> must contain either <Days> or <Date>"),
(Some(days), None) => Ok(GarageLifecycleExpiration::AfterDays(days.0 as usize)),
- (None, Some(date)) => {
- if date.0.parse::<chrono::NaiveDate>().is_err() {
- return Err("Invalid expiration <Date>");
- }
- Ok(GarageLifecycleExpiration::AtDate(date.0))
- }
+ (None, Some(date)) => date
+ .0
+ .parse::<chrono::NaiveDate>()
+ .map(GarageLifecycleExpiration::AtDate)
+ .map_err(|_| "Invalid expiration <Date>"),
}
}
@@ -285,9 +284,9 @@ impl Expiration {
days: Some(IntValue(*days as i64)),
at_date: None,
},
- GarageLifecycleExpiration::AtDate(days) => Expiration {
+ GarageLifecycleExpiration::AtDate(date) => Expiration {
days: None,
- at_date: Some(Value::from(days.as_str())),
+ at_date: Some(Value(date.to_string())),
},
}
}