k8s_openapi_ext/get/
namespace.rs

1use super::*;
2
3pub trait NamespaceGetExt {
4    fn spec(&self) -> Option<&corev1::NamespaceSpec>;
5
6    fn status(&self) -> Option<&corev1::NamespaceStatus>;
7
8    fn finalizers(&self) -> Option<&[String]> {
9        self.spec()?.finalizers.as_deref()
10    }
11
12    fn conditions(&self) -> Option<&[corev1::NamespaceCondition]> {
13        self.status()?.conditions.as_deref()
14    }
15
16    fn phase(&self) -> Option<&str> {
17        self.status()?.phase.as_deref()
18    }
19
20    fn condition(&self, r#type: impl AsRef<str>) -> Option<&corev1::NamespaceCondition> {
21        let r#type = r#type.as_ref();
22        self.conditions()?
23            .iter()
24            .find(|condition| condition.type_ == r#type)
25    }
26}
27
28impl NamespaceGetExt for corev1::Namespace {
29    fn spec(&self) -> Option<&corev1::NamespaceSpec> {
30        self.spec.as_ref()
31    }
32
33    fn status(&self) -> Option<&corev1::NamespaceStatus> {
34        self.status.as_ref()
35    }
36}