pub fn parse_run_requested_at(
annotations: Option<&BTreeMap<String, String>>,
run_command: &str,
) -> Result<Option<DateTime<Utc>>, String>Expand description
Parse the run-requested annotation into the pinned request instant.
Ok(None) = no request; Err = the annotation is present but not an
RFC3339 timestamp (the message says how to fix it). The one timestamp
parser behind every “run it now” surface — Maintenance’s
crate::maintenance::parse_run_annotations delegates here, and both
replication kinds call it directly — so admission and the reconcilers can
never disagree about what a request is (SKILL “one validator, two
callers”).
run_command is the kind’s own kubectl kopiur … run invocation, quoted
verbatim in the fix hint: the annotation is identical across kinds but the
command that stamps it is not, and a fix hint naming the wrong command is
worse than none.
use kopiur_api::common::parse_run_requested_at;
use std::collections::BTreeMap;
assert_eq!(parse_run_requested_at(None, "kubectl kopiur replication run"), Ok(None));
let mut a = BTreeMap::new();
a.insert(
kopiur_api::consts::RUN_REQUESTED_ANNOTATION.to_string(),
"2026-06-11T12:00:00Z".to_string(),
);
let at = parse_run_requested_at(Some(&a), "kubectl kopiur replication run")
.unwrap()
.unwrap();
assert_eq!(at.to_rfc3339(), "2026-06-11T12:00:00+00:00");
a.insert(
kopiur_api::consts::RUN_REQUESTED_ANNOTATION.to_string(),
"yesterday".to_string(),
);
let err = parse_run_requested_at(Some(&a), "kubectl kopiur replication run").unwrap_err();
assert!(err.contains("must be an RFC3339 timestamp"));
assert!(err.contains("kubectl kopiur replication run"));