[pbs-devel] [PATCH proxmox 2/6] subscription: expose the `next_due_date` as an `i64`

Stefan Sterz s.sterz at proxmox.com
Thu Nov 9 16:33:59 CET 2023


internally `SubscriptionInfo` already uses the `parse_next_due` helper
to parse the next due date to an epoch. this exposes a function that
allows us to use the epoch outside of this crate too. for example, a
user of pom may have multiple subscription for the same system. in
that case we want to apply the one with the due date that is furthest
in the future.

Signed-off-by: Stefan Sterz <s.sterz at proxmox.com>
---
 proxmox-subscription/src/subscription_info.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs
index dc10a2a..45f1796 100644
--- a/proxmox-subscription/src/subscription_info.rs
+++ b/proxmox-subscription/src/subscription_info.rs
@@ -286,6 +286,13 @@ impl SubscriptionInfo {
             .ok_or_else(|| format_err!("no product key set"))
             .map(|key| key[..3].parse::<ProductType>())?
     }
+
+    pub fn get_next_due_date(&self) -> Result<i64, Error> {
+        self.nextduedate
+            .as_ref()
+            .ok_or_else(|| format_err!("no next due date set"))
+            .map(|e| parse_next_due(e))?
+    }
 }

 /// Shortcut for md5 sums.
--
2.39.2






More information about the pbs-devel mailing list