// Generated from definition io.k8s.api.scheduling.v1alpha2.PodGroupTemplate
/// PodGroupTemplate represents a template for a set of pods with a scheduling policy.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct PodGroupTemplate {
/// DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.
pub disruption_mode: Option<std::string::String>,
/// Name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.
pub name: std::string::String,
/// 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. 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 available only when the WorkloadAwarePreemption feature gate is enabled.
pub priority: Option<i32>,
/// PriorityClassName indicates the priority that should be considered when scheduling a 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, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.
pub priority_class_name: Option<std::string::String>,
/// 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.
///
/// This is an alpha-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.
///
/// This field is immutable.
pub resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>>,
/// SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.
pub scheduling_constraints: Option<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints>,
/// SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.
pub scheduling_policy: crate::api::scheduling::v1alpha2::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.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_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,
"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<std::string::String> = None;
let mut value_name: 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::v1alpha2::PodGroupResourceClaim>> = None;
let mut value_scheduling_constraints: Option<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints> = None;
let mut value_scheduling_policy: Option<crate::api::scheduling::v1alpha2::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_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(),
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",
"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.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.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.v1alpha2.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": {
"description": "DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.",
"type": "string",
},
"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",
},
"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. 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 available only when the WorkloadAwarePreemption feature gate is enabled.",
"type": "integer",
"format": "int32",
},
"priorityClassName": {
"description": "PriorityClassName indicates the priority that should be considered when scheduling a 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, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.",
"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 an alpha-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::v1alpha2::PodGroupResourceClaim>()),
},
"schedulingConstraints": ({
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::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.".into());
schema_obj
}),
"schedulingPolicy": ({
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy>();
schema_obj.ensure_object().insert("description".into(), "SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into());
schema_obj
}),
},
"required": [
"name",
"schedulingPolicy",
],
})
}
}
#[cfg(feature = "schemars08")]
impl crate::schemars08::JsonSchema for PodGroupTemplate {
fn schema_name() -> std::string::String {
"io.k8s.api.scheduling.v1alpha2.PodGroupTemplate".into()
}
fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("PodGroupTemplate represents a template for a set of pods with a scheduling policy.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
properties: [
(
"disruptionMode".into(),
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
..Default::default()
}),
),
(
"name".into(),
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("Name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
..Default::default()
}),
),
(
"priority".into(),
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("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. 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 available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
format: Some("int32".into()),
..Default::default()
}),
),
(
"priorityClassName".into(),
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("PriorityClassName indicates the priority that should be considered when scheduling a 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, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
..Default::default()
}),
),
(
"resourceClaims".into(),
crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("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 an alpha-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.\n\nThis field is immutable.".into()),
..Default::default()
})),
instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>()))),
..Default::default()
})),
..Default::default()
}),
),
(
"schedulingConstraints".into(),
{
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints>().into_object();
schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.".into()),
..Default::default()
}));
crate::schemars08::schema::Schema::Object(schema_obj)
},
),
(
"schedulingPolicy".into(),
{
let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy>().into_object();
schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
description: Some("SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into()),
..Default::default()
}));
crate::schemars08::schema::Schema::Object(schema_obj)
},
),
].into(),
required: [
"name".into(),
"schedulingPolicy".into(),
].into(),
..Default::default()
})),
..Default::default()
})
}
}