parse_rotation_annotations

Function parse_rotation_annotations 

Source
pub fn parse_rotation_annotations(
    annotations: &BTreeMap<String, String>,
) -> Result<(DateTime<Utc>, Option<DateTime<Utc>>, u32)>
Expand description

Parse rotation tracking annotations from a Kubernetes Secret.

Extracts the created_at, rotate_at, and rotation_count annotations from a Secret’s metadata.

§Arguments

  • annotations - Secret annotations map

§Returns

A tuple of:

  • created_at: Timestamp when the key was created or last rotated
  • rotate_at: Optional timestamp when rotation is due (None if rotation disabled)
  • rotation_count: Number of times the key has been rotated

§Errors

Returns an error if:

  • The created-at annotation is missing
  • Any timestamp cannot be parsed as ISO 8601
  • The rotation-count annotation cannot be parsed as u32

§Examples

use std::collections::BTreeMap;
use bindy::bind9::rndc::parse_rotation_annotations;

let mut annotations = BTreeMap::new();
annotations.insert(
    "bindy.firestoned.io/rndc-created-at".to_string(),
    "2025-01-26T10:00:00Z".to_string()
);
annotations.insert(
    "bindy.firestoned.io/rndc-rotate-at".to_string(),
    "2025-02-25T10:00:00Z".to_string()
);
annotations.insert(
    "bindy.firestoned.io/rndc-rotation-count".to_string(),
    "5".to_string()
);

let (created_at, rotate_at, count) = parse_rotation_annotations(&annotations).unwrap();
assert_eq!(count, 5);