Expand description
Cross-field validation the type system can’t express (ADR §2.2 principle 8).
These are the rules a single struct’s types can’t enforce: “field X is
forbidden only when sibling Y has a particular variant,” “this string must
parse as a cron,” “a discovered backup may only Retain.” They live here as pure
functions so the webhook calls them at admission and the controller calls them
defensively — one validator, two callers (SKILL hard-rule 4). No kube::Client,
no tokio.
§Fail-fast vs. accumulate (see crate::error)
Single-rule helpers return ValidationResult (fail-fast — first problem).
The per-CRD aggregate validators (validate_backup_config, …) return
Vec<ValidationError> so a user sees every independent problem in one apply.
An empty vec means valid.
Functions§
- validate_
backup - Validate a
Backupspec for a given origin, accumulating all problems. - validate_
backup_ config - Validate a
BackupConfigspec, accumulating all problems. - validate_
backup_ deletion_ policy - A
Backup’sdeletionPolicyis legal for its origin (ADR §4.5). - validate_
backup_ schedule - Validate a
BackupSchedulespec, accumulating all problems. - validate_
cluster_ repository - Validate a
ClusterRepositoryspec, accumulating all problems (ADR §3.2). - validate_
consumer_ against_ cluster_ repo - A consumer namespace is permitted by a
ClusterRepository’s tenancy gate (ADR §3.2/§4.3). - validate_
cron - A cron expression parses with the same parser the controller uses at runtime, so bad expressions are rejected at apply time, not at first reconcile (ADR §4.1).
- validate_
maintenance - Validate a
Maintenancespec, accumulating all problems (ADR §3.7). - validate_
repository - Validate a
Repositoryspec, accumulating all problems (ADR §3.1). - validate_
repository_ maintenance - Validate a
spec.maintenanceblock on aRepository/ClusterRepository, accumulating problems (ADR §3.7): - validate_
repository_ no_ inline_ retention - A
Repositoryspec does not carry kopia-side (repo-level) retention policy, which would conflict with CR-driven GFS retention (ADR §4.4 exclusivity). - validate_
repository_ ref - A
RepositoryRefis well-formed: aClusterRepositoryreference is by name only, sonamespaceMUST be absent (ADR §3.2/§3.3). A namespacedRepositoryreference may carry a namespace (cross-namespace references are allowed). - validate_
restore - A
Restorespec is internally consistent (ADR §3.6/§4.6). - validate_
restore_ spec - Validate a
Restorespec, accumulating all problems (wraps the fail-fastvalidate_restorefor caller symmetry). - validate_
source - A single backup
Sourceis well-formed:pvcandpvcSelectorare mutually exclusive, and at least one must be set (ADR §3.3 — modeled as sibling Options because both forms sharesourcePath*keys, so it’s a webhook check, not an enum).