k8s_openapi_ext/get/
statefulset.rs

1use super::*;
2
3pub trait StatefulSetGetExt {
4    fn spec(&self) -> Option<&appsv1::StatefulSetSpec>;
5
6    fn status(&self) -> Option<&appsv1::StatefulSetStatus>;
7
8    // From spec
9    fn min_ready_seconds(&self) -> Option<i32> {
10        self.spec()?.min_ready_seconds
11    }
12
13    // From status
14    fn available_replicas(&self) -> Option<i32> {
15        self.status()?.available_replicas
16    }
17    fn collision_count(&self) -> Option<i32> {
18        self.status()?.collision_count
19    }
20    fn conditions(&self) -> Option<&[appsv1::StatefulSetCondition]> {
21        self.status()?.conditions.as_deref()
22    }
23    fn current_replicas(&self) -> Option<i32> {
24        self.status()?.current_replicas
25    }
26    fn current_revision(&self) -> Option<&str> {
27        self.status()?.current_revision.as_deref()
28    }
29    fn observed_generation(&self) -> Option<i64> {
30        self.status()?.observed_generation
31    }
32    fn ready_replicas(&self) -> Option<i32> {
33        self.status()?.ready_replicas
34    }
35    fn status_replicas(&self) -> i32 {
36        self.status()
37            .map(|status| status.replicas)
38            .unwrap_or_default()
39    }
40    fn update_revision(&self) -> Option<&str> {
41        self.status()?.update_revision.as_deref()
42    }
43    fn updated_replicas(&self) -> Option<i32> {
44        self.status()?.updated_replicas
45    }
46}
47
48impl StatefulSetGetExt for appsv1::StatefulSet {
49    fn spec(&self) -> Option<&appsv1::StatefulSetSpec> {
50        self.spec.as_ref()
51    }
52
53    fn status(&self) -> Option<&appsv1::StatefulSetStatus> {
54        self.status.as_ref()
55    }
56}