Struct kube_runtime::reflector::ObjectRef
source · [−]pub struct ObjectRef<K: Resource> {
pub name: String,
pub namespace: Option<String>,
/* private fields */
}
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 ObjectRef
s 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
name: String
The 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"));
Implementations
Creates ObjectRef
from the resource and dynamic type.
Panics if name is missing (name always exists if the object
was returned from the apiserver)
pub 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.
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
.
Trait Implementations
Auto Trait Implementations
impl<K> RefUnwindSafe for ObjectRef<K> where
<K as Resource>::DynamicType: RefUnwindSafe,
impl<K> UnwindSafe for ObjectRef<K> where
<K as Resource>::DynamicType: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more