k8s_openapi/v1_37/api/scheduling/v1alpha3/
composite_pod_group_spec.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CompositePodGroupSpec {
6 pub disruption_mode: Option<crate::api::scheduling::v1alpha3::CompositeDisruptionMode>,
8
9 pub parent_composite_pod_group_name: Option<std::string::String>,
11
12 pub preemption_policy: Option<std::string::String>,
14
15 pub priority: Option<i32>,
17
18 pub priority_class_name: Option<std::string::String>,
20
21 pub scheduling_constraints: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints>,
23
24 pub scheduling_policy: crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy,
26
27 pub workload_ref: crate::api::scheduling::v1alpha3::WorkloadReference,
29}
30
31impl crate::DeepMerge for CompositePodGroupSpec {
32 fn merge_from(&mut self, other: Self) {
33 crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
34 crate::DeepMerge::merge_from(&mut self.parent_composite_pod_group_name, other.parent_composite_pod_group_name);
35 crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
36 crate::DeepMerge::merge_from(&mut self.priority, other.priority);
37 crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
38 crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
39 crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
40 crate::DeepMerge::merge_from(&mut self.workload_ref, other.workload_ref);
41 }
42}
43
44impl<'de> crate::serde::Deserialize<'de> for CompositePodGroupSpec {
45 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46 #[allow(non_camel_case_types)]
47 enum Field {
48 Key_disruption_mode,
49 Key_parent_composite_pod_group_name,
50 Key_preemption_policy,
51 Key_priority,
52 Key_priority_class_name,
53 Key_scheduling_constraints,
54 Key_scheduling_policy,
55 Key_workload_ref,
56 Other,
57 }
58
59 impl<'de> crate::serde::Deserialize<'de> for Field {
60 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
61 struct Visitor;
62
63 impl crate::serde::de::Visitor<'_> for Visitor {
64 type Value = Field;
65
66 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67 f.write_str("field identifier")
68 }
69
70 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
71 Ok(match v {
72 "disruptionMode" => Field::Key_disruption_mode,
73 "parentCompositePodGroupName" => Field::Key_parent_composite_pod_group_name,
74 "preemptionPolicy" => Field::Key_preemption_policy,
75 "priority" => Field::Key_priority,
76 "priorityClassName" => Field::Key_priority_class_name,
77 "schedulingConstraints" => Field::Key_scheduling_constraints,
78 "schedulingPolicy" => Field::Key_scheduling_policy,
79 "workloadRef" => Field::Key_workload_ref,
80 _ => Field::Other,
81 })
82 }
83 }
84
85 deserializer.deserialize_identifier(Visitor)
86 }
87 }
88
89 struct Visitor;
90
91 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
92 type Value = CompositePodGroupSpec;
93
94 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95 f.write_str("CompositePodGroupSpec")
96 }
97
98 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
99 let mut value_disruption_mode: Option<crate::api::scheduling::v1alpha3::CompositeDisruptionMode> = None;
100 let mut value_parent_composite_pod_group_name: Option<std::string::String> = None;
101 let mut value_preemption_policy: Option<std::string::String> = None;
102 let mut value_priority: Option<i32> = None;
103 let mut value_priority_class_name: Option<std::string::String> = None;
104 let mut value_scheduling_constraints: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints> = None;
105 let mut value_scheduling_policy: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy> = None;
106 let mut value_workload_ref: Option<crate::api::scheduling::v1alpha3::WorkloadReference> = None;
107
108 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
109 match key {
110 Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
111 Field::Key_parent_composite_pod_group_name => value_parent_composite_pod_group_name = crate::serde::de::MapAccess::next_value(&mut map)?,
112 Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
113 Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
114 Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
115 Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
116 Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
117 Field::Key_workload_ref => value_workload_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
118 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
119 }
120 }
121
122 Ok(CompositePodGroupSpec {
123 disruption_mode: value_disruption_mode,
124 parent_composite_pod_group_name: value_parent_composite_pod_group_name,
125 preemption_policy: value_preemption_policy,
126 priority: value_priority,
127 priority_class_name: value_priority_class_name,
128 scheduling_constraints: value_scheduling_constraints,
129 scheduling_policy: value_scheduling_policy.unwrap_or_default(),
130 workload_ref: value_workload_ref.unwrap_or_default(),
131 })
132 }
133 }
134
135 deserializer.deserialize_struct(
136 "CompositePodGroupSpec",
137 &[
138 "disruptionMode",
139 "parentCompositePodGroupName",
140 "preemptionPolicy",
141 "priority",
142 "priorityClassName",
143 "schedulingConstraints",
144 "schedulingPolicy",
145 "workloadRef",
146 ],
147 Visitor,
148 )
149 }
150}
151
152impl crate::serde::Serialize for CompositePodGroupSpec {
153 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
154 let mut state = serializer.serialize_struct(
155 "CompositePodGroupSpec",
156 2 +
157 self.disruption_mode.as_ref().map_or(0, |_| 1) +
158 self.parent_composite_pod_group_name.as_ref().map_or(0, |_| 1) +
159 self.preemption_policy.as_ref().map_or(0, |_| 1) +
160 self.priority.as_ref().map_or(0, |_| 1) +
161 self.priority_class_name.as_ref().map_or(0, |_| 1) +
162 self.scheduling_constraints.as_ref().map_or(0, |_| 1),
163 )?;
164 if let Some(value) = &self.disruption_mode {
165 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
166 }
167 if let Some(value) = &self.parent_composite_pod_group_name {
168 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "parentCompositePodGroupName", value)?;
169 }
170 if let Some(value) = &self.preemption_policy {
171 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
172 }
173 if let Some(value) = &self.priority {
174 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
175 }
176 if let Some(value) = &self.priority_class_name {
177 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
178 }
179 if let Some(value) = &self.scheduling_constraints {
180 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
181 }
182 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
183 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "workloadRef", &self.workload_ref)?;
184 crate::serde::ser::SerializeStruct::end(state)
185 }
186}
187
188#[cfg(feature = "schemars")]
189impl crate::schemars::JsonSchema for CompositePodGroupSpec {
190 fn schema_name() -> std::borrow::Cow<'static, str> {
191 "io.k8s.api.scheduling.v1alpha3.CompositePodGroupSpec".into()
192 }
193
194 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
195 crate::schemars::json_schema!({
196 "description": "CompositePodGroupSpec defines the desired state of CompositePodGroup.",
197 "type": "object",
198 "properties": {
199 "disruptionMode": ({
200 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositeDisruptionMode>();
201 schema_obj.ensure_object().insert("description".into(), "disruptionMode defines the mode in which a given CompositePodGroup can be disrupted. Controllers are expected to fill this field by copying it from a CompositePodGroupTemplate. One of Single, All. Defaults to Single if unset. This field is immutable.".into());
202 schema_obj
203 }),
204 "parentCompositePodGroupName": {
205 "description": "parentCompositePodGroupName contains the name of the parent composite pod group within the same namespace as this composite pod group. It must be a DNS name. If it's nil, then this composite pod group is a root of a workload's hierarchy. This field is immutable.",
206 "type": "string",
207 },
208 "preemptionPolicy": {
209 "description": "preemptionPolicy is the Policy for preempting pods/podgroups with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. When Priority Admission Controller is enabled, it populates this field from PriorityClassName, and defaults to PreemptLowerPriority if value is unset in PriorityClass. This field is immutable. This field is available only when the PodGroupPreemptionPolicy feature gate is enabled.",
210 "type": "string",
211 },
212 "priority": {
213 "description": "priority is the value of priority of this composite pod group. Various system components use this field to find the priority of the composite pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is immutable.",
214 "type": "integer",
215 "format": "int32",
216 },
217 "priorityClassName": {
218 "description": "priorityClassName defines the priority that should be considered when scheduling this CompositePodGroup. Controllers are expected to fill this field by copying it from a CompositePodGroupTemplate. If left unspecified, it is validated and resolved similarly to the PriorityClassName field in Pods (i.e. if no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, the composite pod group's priority will be zero). This field is immutable.",
219 "type": "string",
220 },
221 "schedulingConstraints": ({
222 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints>();
223 schema_obj.ensure_object().insert("description".into(), "schedulingConstraints defines optional scheduling constraints (e.g. topology) for this CompositePodGroup. Controllers are expected to fill this field by copying it from a CompositePodGroupTemplate. This field is immutable.".into());
224 schema_obj
225 }),
226 "schedulingPolicy": ({
227 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy>();
228 schema_obj.ensure_object().insert("description".into(), "schedulingPolicy defines the scheduling policy for this instance of the CompositePodGroup. Controllers are expected to fill this field by copying it from a CompositePodGroupTemplate. This field is immutable.".into());
229 schema_obj
230 }),
231 "workloadRef": ({
232 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::WorkloadReference>();
233 schema_obj.ensure_object().insert("description".into(), "workloadRef references an optional CompositePodGroup template within the Workload object that was used to create the CompositePodGroup. This field is required. This field is immutable.".into());
234 schema_obj
235 }),
236 },
237 "required": [
238 "schedulingPolicy",
239 "workloadRef",
240 ],
241 })
242 }
243}