Skip to main content

describe_identity_change_consumers

Function describe_identity_change_consumers 

Source
pub fn describe_identity_change_consumers(consumers: &[String]) -> String
Expand description

Render the consumer list for ValidationError::RepositoryIdentityWouldFork: the count, then up to [CONSUMER_LIST_SHOWN] namespace/names, then "and N more" for the rest. Also reused verbatim by the webhook to build the admission WARNING when the same change is acknowledged, so the deny message and the warning always name the same policies the same way.

use kopiur_api::error::describe_identity_change_consumers;

assert_eq!(
    describe_identity_change_consumers(&["billing/pg".to_string()]),
    "1 SnapshotPolicy consumer(s) with existing snapshot history (billing/pg)",
);
let many: Vec<String> = (0..7).map(|i| format!("ns/pg-{i}")).collect();
let rendered = describe_identity_change_consumers(&many);
assert!(rendered.starts_with("7 SnapshotPolicy consumer(s)"));
assert!(rendered.ends_with("and 2 more)"), "{rendered}");