pub fn source_shape(source: &Source) -> Result<SourceShape<'_>, ValidationError>Expand description
THE exactly-one-of resolver for a Source’s form.
Never panics: a stored CR can carry an invalid shape (none set, or several — e.g. a
write that raced an old CRD schema), so those come back as a
ValidationError for the caller’s error path rather
than as an unwrap in a reconciler. Mirrors
policy_repositories.
use kopiur_api::snapshot_policy::{Source, SourceShape, PvcSource, source_shape};
let s = Source { pvc: Some(PvcSource { name: "data".into() }), ..Default::default() };
assert!(matches!(source_shape(&s), Ok(SourceShape::Pvc(p)) if p.name == "data"));
// Nothing set is a named error, never a silent default.
assert!(source_shape(&Source::default()).is_err());