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 available_replicas(&self) -> Option<i32> {
35 self.status()?.available_replicas
36 }
37
38 fn collision_count(&self) -> Option<i32> {
39 self.status()?.collision_count
40 }
41
42 fn conditions(&self) -> Option<&[appsv1::StatefulSetCondition]> {
43 self.status()?.conditions.as_deref()
44 }
45
46 fn current_replicas(&self) -> Option<i32> {
47 self.status()?.current_replicas
48 }
49
50 fn current_revision(&self) -> Option<&str> {
51 self.status()?.current_revision.as_deref()
52 }
53
54 fn observed_generation(&self) -> Option<i64> {
55 self.status()?.observed_generation
56 }
57
58 fn ready_replicas(&self) -> Option<i32> {
59 self.status()?.ready_replicas
60 }
61
62 fn status_replicas(&self) -> i32 {
63 self.status()
64 .map(|status| status.replicas)
65 .unwrap_or_default()
66 }
67
68 fn update_revision(&self) -> Option<&str> {
69 self.status()?.update_revision.as_deref()
70 }
71
72 fn updated_replicas(&self) -> Option<i32> {
73 self.status()?.updated_replicas
74 }
75}
76
77impl StatefulSetGetExt for appsv1::StatefulSet {
78 fn spec(&self) -> Option<&appsv1::StatefulSetSpec> {
79 self.spec.as_ref()
80 }
81
82 fn status(&self) -> Option<&appsv1::StatefulSetStatus> {
83 self.status.as_ref()
84 }
85}