pub struct RepositoryRef {
pub kind: RepositoryKind,
pub name: String,
pub namespace: Option<String>,
}Expand description
Discriminated reference from a consumer CR (BackupConfig, Backup,
Restore, Maintenance) to a Repository or ClusterRepository. ADR §3.2.
When kind == ClusterRepository, namespace MUST be absent — enforced by the
admission webhook (api::validate), since the type system cannot express
“this field is forbidden only for one variant of a sibling field”.
Fields§
§kind: RepositoryKindWhich repository CRD this points at; defaults to RepositoryKind::Repository.
name: StringName of the referenced Repository/ClusterRepository.
namespace: Option<String>Cross-namespace Repository reference; ignored/forbidden for ClusterRepository.
Implementations§
Source§impl RepositoryRef
impl RepositoryRef
Sourcepub fn resolves_to(
&self,
owner_namespace: &str,
target_kind: RepositoryKind,
target_name: &str,
target_namespace: Option<&str>,
) -> bool
pub fn resolves_to( &self, owner_namespace: &str, target_kind: RepositoryKind, target_name: &str, target_namespace: Option<&str>, ) -> bool
True if this reference points at the given repository.
owner_namespace is the namespace of the resource that holds the ref
(e.g. the Maintenance CR’s own namespace), used to resolve a namespaced
Repository reference that omits namespace. The match is exhaustive over
RepositoryKind (ADR §5.5):
RepositoryKind::Repository: kind+name must match AND the effective namespace (self.namespaceorowner_namespace) must equaltarget_namespace.RepositoryKind::ClusterRepository: kind+name must match; namespace is ignored on both sides (cluster-scoped).
target_namespace is None for a ClusterRepository target.
use kopiur_api::common::{RepositoryKind, RepositoryRef};
// A namespaced ref that omits `namespace` resolves against the owner's namespace.
let r = RepositoryRef { kind: RepositoryKind::Repository, name: "nas".into(), namespace: None };
assert!(r.resolves_to("apps", RepositoryKind::Repository, "nas", Some("apps")));
assert!(!r.resolves_to("apps", RepositoryKind::Repository, "nas", Some("other")));
// A cluster-scoped target ignores namespace entirely.
let cr = RepositoryRef {
kind: RepositoryKind::ClusterRepository,
name: "hetzner".into(),
namespace: None,
};
assert!(cr.resolves_to("apps", RepositoryKind::ClusterRepository, "hetzner", None));
// Kind must match even when names collide.
assert!(!r.resolves_to("apps", RepositoryKind::ClusterRepository, "nas", None));Trait Implementations§
Source§impl Clone for RepositoryRef
impl Clone for RepositoryRef
Source§fn clone(&self) -> RepositoryRef
fn clone(&self) -> RepositoryRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RepositoryRef
impl Debug for RepositoryRef
Source§impl<'de> Deserialize<'de> for RepositoryRef
impl<'de> Deserialize<'de> for RepositoryRef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for RepositoryRef
impl JsonSchema for RepositoryRef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for RepositoryRef
impl PartialEq for RepositoryRef
Source§impl Serialize for RepositoryRef
impl Serialize for RepositoryRef
impl Eq for RepositoryRef
impl StructuralPartialEq for RepositoryRef
Auto Trait Implementations§
impl Freeze for RepositoryRef
impl RefUnwindSafe for RepositoryRef
impl Send for RepositoryRef
impl Sync for RepositoryRef
impl Unpin for RepositoryRef
impl UnsafeUnpin for RepositoryRef
impl UnwindSafe for RepositoryRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more