Struct kube_runtime::reflector::ObjectRef
source · #[non_exhaustive]pub struct ObjectRef<K: Resource> {
pub dyntype: K::DynamicType,
pub name: String,
pub namespace: Option<String>,
pub extra: Extra,
}Expand description
A typed and namedspaced (if relevant) reference to a Kubernetes object
K may be either the object type or DynamicObject, in which case the
type is stored at runtime. Erased ObjectRefs pointing to different types
are still considered different.
use kube_runtime::reflector::ObjectRef;
use k8s_openapi::api::core::v1::{ConfigMap, Secret};
assert_ne!(
ObjectRef::<ConfigMap>::new("a").erase(),
ObjectRef::<Secret>::new("a").erase(),
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.dyntype: K::DynamicType§name: StringThe name of the object
namespace: Option<String>The namespace of the object
May only be None if the kind is cluster-scoped (not located in a namespace).
Note that it is acceptable for an ObjectRef to a cluster-scoped resource to
have a namespace. These are, however, not considered equal:
assert_ne!(ObjectRef::<ConfigMap>::new("foo"), ObjectRef::new("foo").within("bar"));extra: ExtraExtra information about the object being referred to
This is not considered when comparing objects, but may be used when converting to and from other representations,
such as OwnerReference or ObjectReference.
Implementations§
source§impl<K: Resource> ObjectRef<K>
impl<K: Resource> ObjectRef<K>
pub fn new_with(name: &str, dyntype: K::DynamicType) -> Self
pub fn within(self, namespace: &str) -> Self
sourcepub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Selfwhere
K: Resource,
pub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Selfwhere
K: Resource,
Creates ObjectRef from the resource and dynamic type.
sourcepub fn from_owner_ref(
namespace: Option<&str>,
owner: &OwnerReference,
dyntype: K::DynamicType
) -> Option<Self>
pub fn from_owner_ref( namespace: Option<&str>, owner: &OwnerReference, dyntype: K::DynamicType ) -> Option<Self>
Create an ObjectRef from an OwnerReference
Returns None if the types do not match.
sourcepub fn into_kind_unchecked<K2: Resource>(
self,
dt2: K2::DynamicType
) -> ObjectRef<K2>
pub fn into_kind_unchecked<K2: Resource>( self, dt2: K2::DynamicType ) -> ObjectRef<K2>
Convert into a reference to K2
Note that no checking is done on whether this conversion makes sense. For example, every Service
has a corresponding Endpoints, but it wouldn’t make sense to convert a Pod into a Deployment.
pub fn erase(self) -> ObjectRef<DynamicObject>
Trait Implementations§
source§impl<K: Resource> From<ObjectRef<K>> for ObjectReference
impl<K: Resource> From<ObjectRef<K>> for ObjectReference
source§impl<K: Resource> From<ObjectRef<K>> for ReconcileRequest<K>
impl<K: Resource> From<ObjectRef<K>> for ReconcileRequest<K>
source§impl<K: Resource> PartialEq for ObjectRef<K>where
K::DynamicType: PartialEq,
impl<K: Resource> PartialEq for ObjectRef<K>where
K::DynamicType: PartialEq,
impl<K: Resource> Eq for ObjectRef<K>where
K::DynamicType: Eq,
Auto Trait Implementations§
impl<K> RefUnwindSafe for ObjectRef<K>where
<K as Resource>::DynamicType: RefUnwindSafe,
impl<K> Send for ObjectRef<K>
impl<K> Sync for ObjectRef<K>
impl<K> Unpin for ObjectRef<K>where
<K as Resource>::DynamicType: Unpin,
impl<K> UnwindSafe for ObjectRef<K>where
<K as Resource>::DynamicType: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§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.