Skip to main content

describe_overlapping_identities

Function describe_overlapping_identities 

Source
pub fn describe_overlapping_identities(identities: &[String]) -> String
Expand description

Render the overlap list for ValidationError::SnapshotReplicationOverlapMirrorSource: the count, then up to [CONSUMER_LIST_SHOWN] identities, then "and N more". Also reused verbatim by the webhook to build the non-blocking admission WARNING for the same overlap without mirrorSource, so the deny message and the warning always name the same identities the same way.

use kopiur_api::error::describe_overlapping_identities;

assert_eq!(
    describe_overlapping_identities(&["pg@billing:/pvc/data".to_string()]),
    "1 destination-side SnapshotPolicy identity(ies) (pg@billing:/pvc/data)",
);
let many: Vec<String> = (0..7).map(|i| format!("pg-{i}@ns:/p")).collect();
let rendered = describe_overlapping_identities(&many);
assert!(rendered.starts_with("7 destination-side"));
assert!(rendered.ends_with("and 2 more)"), "{rendered}");