k8s_openapi_ext/get/
statefulset.rs1use super::*;
2
3pub trait StatefulSetGetExt {
4 fn spec(&self) -> Option<&appsv1::StatefulSetSpec>;
5
6 fn status(&self) -> Option<&appsv1::StatefulSetStatus>;
7
8 fn ordinals(&self) -> Option<i32> {
10 self.spec()?.ordinals.as_ref()?.start
11 }
12
13 fn pod_management_policy(&self) -> Option<&str> {
14 self.spec()?.pod_management_policy.as_deref()
15 }
16
17 fn revision_history_limit(&self) -> Option<i32> {
18 self.spec()?.revision_history_limit
19 }
20
21 fn service_name(&self) -> Option<&str> {
22 self.spec()?.service_name.as_deref()
23 }
24
25 fn spec_replicas(&self) -> Option<i32> {
26 self.spec()?.replicas
27 }
28
29 fn min_ready_seconds(&self) -> Option<i32> {
30 self.spec()?.min_ready_seconds
31 }
32
33 fn template(&self) -> Option<&corev1::PodTemplateSpec> {
35 self.spec().map(|spec| &spec.template)
36 }
37
38 fn available_replicas(&self) -> Option<i32> {
40 self.status()?.available_replicas
41 }
42
43 fn collision_count(&self) -> Option<i32> {
47 self.status()?.collision_count
48 }
49
50 fn conditions(&self) -> Option<&[appsv1::StatefulSetCondition]> {
52 self.status()?.conditions.as_deref()
53 }
54
55 fn current_replicas(&self) -> Option<i32> {
57 self.status()?.current_replicas
58 }
59
60 fn current_revision(&self) -> Option<&str> {
62 self.status()?.current_revision.as_deref()
63 }
64
65 fn observed_generation(&self) -> Option<i64> {
68 self.status()?.observed_generation
69 }
70
71 fn ready_replicas(&self) -> Option<i32> {
73 self.status()?.ready_replicas
74 }
75
76 fn status_replicas(&self) -> i32 {
78 self.status()
79 .map(|status| status.replicas)
80 .unwrap_or_default()
81 }
82
83 fn update_revision(&self) -> Option<&str> {
85 self.status()?.update_revision.as_deref()
86 }
87
88 fn updated_replicas(&self) -> Option<i32> {
90 self.status()?.updated_replicas
91 }
92}
93
94impl StatefulSetGetExt for appsv1::StatefulSet {
95 fn spec(&self) -> Option<&appsv1::StatefulSetSpec> {
96 self.spec.as_ref()
97 }
98
99 fn status(&self) -> Option<&appsv1::StatefulSetStatus> {
100 self.status.as_ref()
101 }
102}