#[derive(Clone, Debug, Default, PartialEq)]
pub struct PodGroupTemplate {
pub disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode>,
pub name: std::string::String,
pub preemption_policy: Option<std::string::String>,
pub priority: Option<i32>,
pub priority_class_name: Option<std::string::String>,
pub resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>>,
pub scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>,
pub scheduling_policy: crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy,
}
impl crate::DeepMerge for PodGroupTemplate {
fn merge_from(&mut self, other: Self) {
crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
crate::DeepMerge::merge_from(&mut self.name, other.name);
crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
crate::DeepMerge::merge_from(&mut self.priority, other.priority);
crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
crate::merge_strategies::list::map(
&mut self.resource_claims,
other.resource_claims,
&[|lhs, rhs| lhs.name == rhs.name],
|current_item, other_item| {
crate::DeepMerge::merge_from(current_item, other_item);
},
);
crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
}
}
impl<'de> crate::serde::Deserialize<'de> for PodGroupTemplate {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
enum Field {
Key_disruption_mode,
Key_name,
Key_preemption_policy,
Key_priority,
Key_priority_class_name,
Key_resource_claims,
Key_scheduling_constraints,
Key_scheduling_policy,
Other,
}
impl<'de> crate::serde::Deserialize<'de> for Field {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
struct Visitor;
impl crate::serde::de::Visitor<'_> for Visitor {
type Value = Field;
fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str("field identifier")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
Ok(match v {
"disruptionMode" => Field::Key_disruption_mode,
"name" => Field::Key_name,
"preemptionPolicy" => Field::Key_preemption_policy,
"priority" => Field::Key_priority,
"priorityClassName" => Field::Key_priority_class_name,
"resourceClaims" => Field::Key_resource_claims,
"schedulingConstraints" => Field::Key_scheduling_constraints,
"schedulingPolicy" => Field::Key_scheduling_policy,
_ => Field::Other,
})
}
}
deserializer.deserialize_identifier(Visitor)
}
}
struct Visitor;
impl<'de> crate::serde::de::Visitor<'de> for Visitor {
type Value = PodGroupTemplate;
fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str("PodGroupTemplate")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
let mut value_disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode> = None;
let mut value_name: Option<std::string::String> = None;
let mut value_preemption_policy: Option<std::string::String> = None;
let mut value_priority: Option<i32> = None;
let mut value_priority_class_name: Option<std::string::String> = None;
let mut value_resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>> = None;
let mut value_scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints> = None;
let mut value_scheduling_policy: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy> = None;
while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
match key {
Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_resource_claims => value_resource_claims = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
}
}
Ok(PodGroupTemplate {
disruption_mode: value_disruption_mode,
name: value_name.unwrap_or_default(),
preemption_policy: value_preemption_policy,
priority: value_priority,
priority_class_name: value_priority_class_name,
resource_claims: value_resource_claims,
scheduling_constraints: value_scheduling_constraints,
scheduling_policy: value_scheduling_policy.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct(
"PodGroupTemplate",
&[
"disruptionMode",
"name",
"preemptionPolicy",
"priority",
"priorityClassName",
"resourceClaims",
"schedulingConstraints",
"schedulingPolicy",
],
Visitor,
)
}
}
impl crate::serde::Serialize for PodGroupTemplate {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
let mut state = serializer.serialize_struct(
"PodGroupTemplate",
2 +
self.disruption_mode.as_ref().map_or(0, |_| 1) +
self.preemption_policy.as_ref().map_or(0, |_| 1) +
self.priority.as_ref().map_or(0, |_| 1) +
self.priority_class_name.as_ref().map_or(0, |_| 1) +
self.resource_claims.as_ref().map_or(0, |_| 1) +
self.scheduling_constraints.as_ref().map_or(0, |_| 1),
)?;
if let Some(value) = &self.disruption_mode {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
}
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
if let Some(value) = &self.preemption_policy {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
}
if let Some(value) = &self.priority {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
}
if let Some(value) = &self.priority_class_name {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
}
if let Some(value) = &self.resource_claims {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaims", value)?;
}
if let Some(value) = &self.scheduling_constraints {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
}
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
crate::serde::ser::SerializeStruct::end(state)
}
}
#[cfg(feature = "schemars")]
impl crate::schemars::JsonSchema for PodGroupTemplate {
fn schema_name() -> std::borrow::Cow<'static, str> {
"io.k8s.api.scheduling.v1beta1.PodGroupTemplate".into()
}
fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
crate::schemars::json_schema!({
"description": "PodGroupTemplate represents a template for a set of pods with a scheduling policy.",
"type": "object",
"properties": {
"disruptionMode": ({
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::DisruptionMode>();
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());
schema_obj
}),
"name": {
"description": "name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.",
"type": "string",
},
"preemptionPolicy": {
"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.",
"type": "string",
},
"priority": {
"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.",
"type": "integer",
"format": "int32",
},
"priorityClassName": {
"description": "priorityClassName indicates the priority that should be considered when scheduling a pod group created from this template. This field is immutable.",
"type": "string",
},
"resourceClaims": {
"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.",
"type": "array",
"items": (__gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupResourceClaim>()),
},
"schedulingConstraints": ({
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>();
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());
schema_obj
}),
"schedulingPolicy": ({
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy>();
schema_obj.ensure_object().insert("description".into(), "schedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into());
schema_obj
}),
},
"required": [
"name",
"schedulingPolicy",
],
})
}
}