Skip to main content

k8s_openapi/v1_37/api/scheduling/v1alpha3/
composite_pod_group_template.rs

1// Generated from definition io.k8s.api.scheduling.v1alpha3.CompositePodGroupTemplate
2
3/// CompositePodGroupTemplate represents a template for a CompositePodGroup with a scheduling policy.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CompositePodGroupTemplate {
6    /// compositePodGroupTemplates is the list of templates for children CompositePodGroups. The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates or PodGroupTemplates must be set.
7    pub composite_pod_group_templates: Option<std::vec::Vec<crate::api::scheduling::v1alpha3::CompositePodGroupTemplate>>,
8
9    /// disruptionMode defines the mode in which a given CompositePodGroup can be disrupted. One of Single, All. This field is immutable.
10    pub disruption_mode: Option<crate::api::scheduling::v1alpha3::CompositeDisruptionMode>,
11
12    /// name is a unique identifier for the CompositePodGroupTemplate within the Workload. It must be a DNS label. This field is required.
13    pub name: std::string::String,
14
15    /// podGroupTemplates is the list of templates for children PodGroups. The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates or PodGroupTemplates must be set.
16    pub pod_group_templates: Option<std::vec::Vec<crate::api::scheduling::v1alpha3::PodGroupTemplate>>,
17
18    /// 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.
19    pub preemption_policy: Option<std::string::String>,
20
21    /// priority is the value of priority of composite pod groups created from this template. 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.
22    pub priority: Option<i32>,
23
24    /// priorityClassName indicates the priority that should be considered when scheduling a composite pod group created from this template. If no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, composite pod groups created from this template will have the priority set to zero. This field is immutable.
25    pub priority_class_name: Option<std::string::String>,
26
27    /// schedulingConstraints defines optional scheduling constraints (e.g. topology) for this CompositePodGroupTemplate. This field is immutable.
28    pub scheduling_constraints: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints>,
29
30    /// schedulingPolicy defines the scheduling policy for this template.
31    pub scheduling_policy: crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy,
32}
33
34impl crate::DeepMerge for CompositePodGroupTemplate {
35    fn merge_from(&mut self, other: Self) {
36        crate::merge_strategies::list::map(
37            &mut self.composite_pod_group_templates,
38            other.composite_pod_group_templates,
39            &[|lhs, rhs| lhs.name == rhs.name],
40            |current_item, other_item| {
41                crate::DeepMerge::merge_from(current_item, other_item);
42            },
43        );
44        crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
45        crate::DeepMerge::merge_from(&mut self.name, other.name);
46        crate::merge_strategies::list::map(
47            &mut self.pod_group_templates,
48            other.pod_group_templates,
49            &[|lhs, rhs| lhs.name == rhs.name],
50            |current_item, other_item| {
51                crate::DeepMerge::merge_from(current_item, other_item);
52            },
53        );
54        crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
55        crate::DeepMerge::merge_from(&mut self.priority, other.priority);
56        crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
57        crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
58        crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
59    }
60}
61
62impl<'de> crate::serde::Deserialize<'de> for CompositePodGroupTemplate {
63    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
64        #[allow(non_camel_case_types)]
65        enum Field {
66            Key_composite_pod_group_templates,
67            Key_disruption_mode,
68            Key_name,
69            Key_pod_group_templates,
70            Key_preemption_policy,
71            Key_priority,
72            Key_priority_class_name,
73            Key_scheduling_constraints,
74            Key_scheduling_policy,
75            Other,
76        }
77
78        impl<'de> crate::serde::Deserialize<'de> for Field {
79            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
80                struct Visitor;
81
82                impl crate::serde::de::Visitor<'_> for Visitor {
83                    type Value = Field;
84
85                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
86                        f.write_str("field identifier")
87                    }
88
89                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
90                        Ok(match v {
91                            "compositePodGroupTemplates" => Field::Key_composite_pod_group_templates,
92                            "disruptionMode" => Field::Key_disruption_mode,
93                            "name" => Field::Key_name,
94                            "podGroupTemplates" => Field::Key_pod_group_templates,
95                            "preemptionPolicy" => Field::Key_preemption_policy,
96                            "priority" => Field::Key_priority,
97                            "priorityClassName" => Field::Key_priority_class_name,
98                            "schedulingConstraints" => Field::Key_scheduling_constraints,
99                            "schedulingPolicy" => Field::Key_scheduling_policy,
100                            _ => Field::Other,
101                        })
102                    }
103                }
104
105                deserializer.deserialize_identifier(Visitor)
106            }
107        }
108
109        struct Visitor;
110
111        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
112            type Value = CompositePodGroupTemplate;
113
114            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
115                f.write_str("CompositePodGroupTemplate")
116            }
117
118            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
119                let mut value_composite_pod_group_templates: Option<std::vec::Vec<crate::api::scheduling::v1alpha3::CompositePodGroupTemplate>> = None;
120                let mut value_disruption_mode: Option<crate::api::scheduling::v1alpha3::CompositeDisruptionMode> = None;
121                let mut value_name: Option<std::string::String> = None;
122                let mut value_pod_group_templates: Option<std::vec::Vec<crate::api::scheduling::v1alpha3::PodGroupTemplate>> = None;
123                let mut value_preemption_policy: Option<std::string::String> = None;
124                let mut value_priority: Option<i32> = None;
125                let mut value_priority_class_name: Option<std::string::String> = None;
126                let mut value_scheduling_constraints: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints> = None;
127                let mut value_scheduling_policy: Option<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy> = None;
128
129                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
130                    match key {
131                        Field::Key_composite_pod_group_templates => value_composite_pod_group_templates = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_pod_group_templates => value_pod_group_templates = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
136                        Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
137                        Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
138                        Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
139                        Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
140                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
141                    }
142                }
143
144                Ok(CompositePodGroupTemplate {
145                    composite_pod_group_templates: value_composite_pod_group_templates,
146                    disruption_mode: value_disruption_mode,
147                    name: value_name.unwrap_or_default(),
148                    pod_group_templates: value_pod_group_templates,
149                    preemption_policy: value_preemption_policy,
150                    priority: value_priority,
151                    priority_class_name: value_priority_class_name,
152                    scheduling_constraints: value_scheduling_constraints,
153                    scheduling_policy: value_scheduling_policy.unwrap_or_default(),
154                })
155            }
156        }
157
158        deserializer.deserialize_struct(
159            "CompositePodGroupTemplate",
160            &[
161                "compositePodGroupTemplates",
162                "disruptionMode",
163                "name",
164                "podGroupTemplates",
165                "preemptionPolicy",
166                "priority",
167                "priorityClassName",
168                "schedulingConstraints",
169                "schedulingPolicy",
170            ],
171            Visitor,
172        )
173    }
174}
175
176impl crate::serde::Serialize for CompositePodGroupTemplate {
177    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
178        let mut state = serializer.serialize_struct(
179            "CompositePodGroupTemplate",
180            2 +
181            self.composite_pod_group_templates.as_ref().map_or(0, |_| 1) +
182            self.disruption_mode.as_ref().map_or(0, |_| 1) +
183            self.pod_group_templates.as_ref().map_or(0, |_| 1) +
184            self.preemption_policy.as_ref().map_or(0, |_| 1) +
185            self.priority.as_ref().map_or(0, |_| 1) +
186            self.priority_class_name.as_ref().map_or(0, |_| 1) +
187            self.scheduling_constraints.as_ref().map_or(0, |_| 1),
188        )?;
189        if let Some(value) = &self.composite_pod_group_templates {
190            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "compositePodGroupTemplates", value)?;
191        }
192        if let Some(value) = &self.disruption_mode {
193            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
194        }
195        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
196        if let Some(value) = &self.pod_group_templates {
197            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podGroupTemplates", value)?;
198        }
199        if let Some(value) = &self.preemption_policy {
200            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
201        }
202        if let Some(value) = &self.priority {
203            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
204        }
205        if let Some(value) = &self.priority_class_name {
206            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
207        }
208        if let Some(value) = &self.scheduling_constraints {
209            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
210        }
211        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
212        crate::serde::ser::SerializeStruct::end(state)
213    }
214}
215
216#[cfg(feature = "schemars")]
217impl crate::schemars::JsonSchema for CompositePodGroupTemplate {
218    fn schema_name() -> std::borrow::Cow<'static, str> {
219        "io.k8s.api.scheduling.v1alpha3.CompositePodGroupTemplate".into()
220    }
221
222    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
223        crate::schemars::json_schema!({
224            "description": "CompositePodGroupTemplate represents a template for a CompositePodGroup with a scheduling policy.",
225            "type": "object",
226            "properties": {
227                "compositePodGroupTemplates": {
228                    "description": "compositePodGroupTemplates is the list of templates for children CompositePodGroups. The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates or PodGroupTemplates must be set.",
229                    "type": "array",
230                    "items": (__gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositePodGroupTemplate>()),
231                },
232                "disruptionMode": ({
233                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositeDisruptionMode>();
234                    schema_obj.ensure_object().insert("description".into(), "disruptionMode defines the mode in which a given CompositePodGroup can be disrupted. One of Single, All. This field is immutable.".into());
235                    schema_obj
236                }),
237                "name": {
238                    "description": "name is a unique identifier for the CompositePodGroupTemplate within the Workload. It must be a DNS label. This field is required.",
239                    "type": "string",
240                },
241                "podGroupTemplates": {
242                    "description": "podGroupTemplates is the list of templates for children PodGroups. The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates or PodGroupTemplates must be set.",
243                    "type": "array",
244                    "items": (__gen.subschema_for::<crate::api::scheduling::v1alpha3::PodGroupTemplate>()),
245                },
246                "preemptionPolicy": {
247                    "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.",
248                    "type": "string",
249                },
250                "priority": {
251                    "description": "priority is the value of priority of composite pod groups created from this template. 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.",
252                    "type": "integer",
253                    "format": "int32",
254                },
255                "priorityClassName": {
256                    "description": "priorityClassName indicates the priority that should be considered when scheduling a composite pod group created from this template. If no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, composite pod groups created from this template will have the priority set to zero. This field is immutable.",
257                    "type": "string",
258                },
259                "schedulingConstraints": ({
260                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingConstraints>();
261                    schema_obj.ensure_object().insert("description".into(), "schedulingConstraints defines optional scheduling constraints (e.g. topology) for this CompositePodGroupTemplate. This field is immutable.".into());
262                    schema_obj
263                }),
264                "schedulingPolicy": ({
265                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha3::CompositePodGroupSchedulingPolicy>();
266                    schema_obj.ensure_object().insert("description".into(), "schedulingPolicy defines the scheduling policy for this template.".into());
267                    schema_obj
268                }),
269            },
270            "required": [
271                "name",
272                "schedulingPolicy",
273            ],
274        })
275    }
276}