pub fn validate_seed_not_self(
seed: Option<&SeedSpec>,
self_kind: RepositoryKind,
self_name: &str,
self_namespace: &str,
) -> ValidationResultExpand description
A migrate-mode seed must not point at the repository being defined. Uses the
shared crate::common::repo_key normalization, so a Repository naming
its own namespace explicitly and one omitting it are both caught. Needs the
CR’s own identity, which the spec does not carry.
use kopiur_api::common::RepositoryKind;
use kopiur_api::seed::{SeedSpec, SeedSource};
use kopiur_api::validate::validate_seed_not_self;
let seed = |from: serde_json::Value| -> SeedSpec {
SeedSpec { from: serde_json::from_value(from).unwrap(), sync: None, migrate: None,
allow_empty_source: false, failure_policy: None, credential_projection: None }
};
let itself = seed(serde_json::json!({ "repository": { "name": "nas" } }));
assert!(
validate_seed_not_self(Some(&itself), RepositoryKind::Repository, "nas", "backups")
.is_err()
);
let other = seed(serde_json::json!({ "repository": { "name": "offsite" } }));
assert!(
validate_seed_not_self(Some(&other), RepositoryKind::Repository, "nas", "backups").is_ok()
);