k8s_openapi/v1_37/api/scheduling/v1beta1/
pod_group_template.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodGroupTemplate {
6 pub disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode>,
8
9 pub name: 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 resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>>,
27
28 pub scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>,
30
31 pub scheduling_policy: crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy,
33}
34
35impl crate::DeepMerge for PodGroupTemplate {
36 fn merge_from(&mut self, other: Self) {
37 crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
38 crate::DeepMerge::merge_from(&mut self.name, other.name);
39 crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
40 crate::DeepMerge::merge_from(&mut self.priority, other.priority);
41 crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
42 crate::merge_strategies::list::map(
43 &mut self.resource_claims,
44 other.resource_claims,
45 &[|lhs, rhs| lhs.name == rhs.name],
46 |current_item, other_item| {
47 crate::DeepMerge::merge_from(current_item, other_item);
48 },
49 );
50 crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
51 crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
52 }
53}
54
55impl<'de> crate::serde::Deserialize<'de> for PodGroupTemplate {
56 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
57 #[allow(non_camel_case_types)]
58 enum Field {
59 Key_disruption_mode,
60 Key_name,
61 Key_preemption_policy,
62 Key_priority,
63 Key_priority_class_name,
64 Key_resource_claims,
65 Key_scheduling_constraints,
66 Key_scheduling_policy,
67 Other,
68 }
69
70 impl<'de> crate::serde::Deserialize<'de> for Field {
71 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
72 struct Visitor;
73
74 impl crate::serde::de::Visitor<'_> for Visitor {
75 type Value = Field;
76
77 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
78 f.write_str("field identifier")
79 }
80
81 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
82 Ok(match v {
83 "disruptionMode" => Field::Key_disruption_mode,
84 "name" => Field::Key_name,
85 "preemptionPolicy" => Field::Key_preemption_policy,
86 "priority" => Field::Key_priority,
87 "priorityClassName" => Field::Key_priority_class_name,
88 "resourceClaims" => Field::Key_resource_claims,
89 "schedulingConstraints" => Field::Key_scheduling_constraints,
90 "schedulingPolicy" => Field::Key_scheduling_policy,
91 _ => Field::Other,
92 })
93 }
94 }
95
96 deserializer.deserialize_identifier(Visitor)
97 }
98 }
99
100 struct Visitor;
101
102 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
103 type Value = PodGroupTemplate;
104
105 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106 f.write_str("PodGroupTemplate")
107 }
108
109 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
110 let mut value_disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode> = None;
111 let mut value_name: Option<std::string::String> = None;
112 let mut value_preemption_policy: Option<std::string::String> = None;
113 let mut value_priority: Option<i32> = None;
114 let mut value_priority_class_name: Option<std::string::String> = None;
115 let mut value_resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>> = None;
116 let mut value_scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints> = None;
117 let mut value_scheduling_policy: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy> = None;
118
119 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
120 match key {
121 Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
122 Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
123 Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
124 Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
125 Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
126 Field::Key_resource_claims => value_resource_claims = crate::serde::de::MapAccess::next_value(&mut map)?,
127 Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
128 Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
129 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
130 }
131 }
132
133 Ok(PodGroupTemplate {
134 disruption_mode: value_disruption_mode,
135 name: value_name.unwrap_or_default(),
136 preemption_policy: value_preemption_policy,
137 priority: value_priority,
138 priority_class_name: value_priority_class_name,
139 resource_claims: value_resource_claims,
140 scheduling_constraints: value_scheduling_constraints,
141 scheduling_policy: value_scheduling_policy.unwrap_or_default(),
142 })
143 }
144 }
145
146 deserializer.deserialize_struct(
147 "PodGroupTemplate",
148 &[
149 "disruptionMode",
150 "name",
151 "preemptionPolicy",
152 "priority",
153 "priorityClassName",
154 "resourceClaims",
155 "schedulingConstraints",
156 "schedulingPolicy",
157 ],
158 Visitor,
159 )
160 }
161}
162
163impl crate::serde::Serialize for PodGroupTemplate {
164 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
165 let mut state = serializer.serialize_struct(
166 "PodGroupTemplate",
167 2 +
168 self.disruption_mode.as_ref().map_or(0, |_| 1) +
169 self.preemption_policy.as_ref().map_or(0, |_| 1) +
170 self.priority.as_ref().map_or(0, |_| 1) +
171 self.priority_class_name.as_ref().map_or(0, |_| 1) +
172 self.resource_claims.as_ref().map_or(0, |_| 1) +
173 self.scheduling_constraints.as_ref().map_or(0, |_| 1),
174 )?;
175 if let Some(value) = &self.disruption_mode {
176 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
177 }
178 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
179 if let Some(value) = &self.preemption_policy {
180 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
181 }
182 if let Some(value) = &self.priority {
183 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
184 }
185 if let Some(value) = &self.priority_class_name {
186 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
187 }
188 if let Some(value) = &self.resource_claims {
189 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaims", value)?;
190 }
191 if let Some(value) = &self.scheduling_constraints {
192 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
193 }
194 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
195 crate::serde::ser::SerializeStruct::end(state)
196 }
197}
198
199#[cfg(feature = "schemars")]
200impl crate::schemars::JsonSchema for PodGroupTemplate {
201 fn schema_name() -> std::borrow::Cow<'static, str> {
202 "io.k8s.api.scheduling.v1beta1.PodGroupTemplate".into()
203 }
204
205 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
206 crate::schemars::json_schema!({
207 "description": "PodGroupTemplate represents a template for a set of pods with a scheduling policy.",
208 "type": "object",
209 "properties": {
210 "disruptionMode": ({
211 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::DisruptionMode>();
212 schema_obj.ensure_object().insert("description".into(), "disruptionMode defines the mode in which a given PodGroup can be disrupted. One of Single, All. This field is immutable.".into());
213 schema_obj
214 }),
215 "name": {
216 "description": "name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.",
217 "type": "string",
218 },
219 "preemptionPolicy": {
220 "description": "preemptionPolicy is the Policy for preempting pods/podgroups with lower priority. One of Never, PreemptLowerPriority. This field is immutable. This field is available only when the PodGroupPreemptionPolicy feature gate is enabled.",
221 "type": "string",
222 },
223 "priority": {
224 "description": "priority is the value of priority of pod groups created from this template. Various system components use this field to find the priority of the pod group. The higher the value, the higher the priority. This field is immutable.",
225 "type": "integer",
226 "format": "int32",
227 },
228 "priorityClassName": {
229 "description": "priorityClassName indicates the priority that should be considered when scheduling a pod group created from this template. This field is immutable.",
230 "type": "string",
231 },
232 "resourceClaims": {
233 "description": "resourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.\n\nThis is a beta-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.\n\nThis field is immutable.",
234 "type": "array",
235 "items": (__gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupResourceClaim>()),
236 },
237 "schedulingConstraints": ({
238 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>();
239 schema_obj.ensure_object().insert("description".into(), "schedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled. This field is immutable.".into());
240 schema_obj
241 }),
242 "schedulingPolicy": ({
243 let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy>();
244 schema_obj.ensure_object().insert("description".into(), "schedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into());
245 schema_obj
246 }),
247 },
248 "required": [
249 "name",
250 "schedulingPolicy",
251 ],
252 })
253 }
254}