k8s_openapi/v1_30/api/resource/v1alpha2/
pod_scheduling_context_spec.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodSchedulingContextSpec {
6 pub potential_nodes: Option<std::vec::Vec<std::string::String>>,
10
11 pub selected_node: Option<std::string::String>,
13}
14
15impl crate::DeepMerge for PodSchedulingContextSpec {
16 fn merge_from(&mut self, other: Self) {
17 crate::merge_strategies::list::atomic(&mut self.potential_nodes, other.potential_nodes);
18 crate::DeepMerge::merge_from(&mut self.selected_node, other.selected_node);
19 }
20}
21
22impl<'de> crate::serde::Deserialize<'de> for PodSchedulingContextSpec {
23 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
24 #[allow(non_camel_case_types)]
25 enum Field {
26 Key_potential_nodes,
27 Key_selected_node,
28 Other,
29 }
30
31 impl<'de> crate::serde::Deserialize<'de> for Field {
32 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
33 struct Visitor;
34
35 impl crate::serde::de::Visitor<'_> for Visitor {
36 type Value = Field;
37
38 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
39 f.write_str("field identifier")
40 }
41
42 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
43 Ok(match v {
44 "potentialNodes" => Field::Key_potential_nodes,
45 "selectedNode" => Field::Key_selected_node,
46 _ => Field::Other,
47 })
48 }
49 }
50
51 deserializer.deserialize_identifier(Visitor)
52 }
53 }
54
55 struct Visitor;
56
57 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
58 type Value = PodSchedulingContextSpec;
59
60 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
61 f.write_str("PodSchedulingContextSpec")
62 }
63
64 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
65 let mut value_potential_nodes: Option<std::vec::Vec<std::string::String>> = None;
66 let mut value_selected_node: Option<std::string::String> = None;
67
68 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
69 match key {
70 Field::Key_potential_nodes => value_potential_nodes = crate::serde::de::MapAccess::next_value(&mut map)?,
71 Field::Key_selected_node => value_selected_node = crate::serde::de::MapAccess::next_value(&mut map)?,
72 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
73 }
74 }
75
76 Ok(PodSchedulingContextSpec {
77 potential_nodes: value_potential_nodes,
78 selected_node: value_selected_node,
79 })
80 }
81 }
82
83 deserializer.deserialize_struct(
84 "PodSchedulingContextSpec",
85 &[
86 "potentialNodes",
87 "selectedNode",
88 ],
89 Visitor,
90 )
91 }
92}
93
94impl crate::serde::Serialize for PodSchedulingContextSpec {
95 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
96 let mut state = serializer.serialize_struct(
97 "PodSchedulingContextSpec",
98 self.potential_nodes.as_ref().map_or(0, |_| 1) +
99 self.selected_node.as_ref().map_or(0, |_| 1),
100 )?;
101 if let Some(value) = &self.potential_nodes {
102 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "potentialNodes", value)?;
103 }
104 if let Some(value) = &self.selected_node {
105 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "selectedNode", value)?;
106 }
107 crate::serde::ser::SerializeStruct::end(state)
108 }
109}
110
111#[cfg(feature = "schemars")]
112impl crate::schemars::JsonSchema for PodSchedulingContextSpec {
113 fn schema_name() -> std::borrow::Cow<'static, str> {
114 "io.k8s.api.resource.v1alpha2.PodSchedulingContextSpec".into()
115 }
116
117 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
118 crate::schemars::json_schema!({
119 "description": "PodSchedulingContextSpec describes where resources for the Pod are needed.",
120 "type": "object",
121 "properties": {
122 "potentialNodes": {
123 "description": "PotentialNodes lists nodes where the Pod might be able to run.\n\nThe size of this field is limited to 128. This is large enough for many clusters. Larger clusters may need more attempts to find a node that suits all pending resources. This may get increased in the future, but not reduced.",
124 "type": "array",
125 "items": {
126 "type": "string",
127 },
128 },
129 "selectedNode": {
130 "description": "SelectedNode is the node for which allocation of ResourceClaims that are referenced by the Pod and that use \"WaitForFirstConsumer\" allocation is to be attempted.",
131 "type": "string",
132 },
133 },
134 })
135 }
136}