1// Generated from definition io.k8s.api.node.v1.RuntimeClass
23/// RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://kubernetes.io/docs/concepts/containers/runtime-class/
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RuntimeClass {
6/// handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called "runc" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.
7pub handler: std::string::String,
89/// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
10pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
1112/// overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see
13 /// https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/
14pub overhead: Option<crate::api::node::v1::Overhead>,
1516/// scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.
17pub scheduling: Option<crate::api::node::v1::Scheduling>,
18}
1920impl crate::Resource for RuntimeClass {
21const API_VERSION: &'static str = "node.k8s.io/v1";
22const GROUP: &'static str = "node.k8s.io";
23const KIND: &'static str = "RuntimeClass";
24const VERSION: &'static str = "v1";
25const URL_PATH_SEGMENT: &'static str = "runtimeclasses";
26type Scope = crate::ClusterResourceScope;
27}
2829impl crate::ListableResource for RuntimeClass {
30const LIST_KIND: &'static str = "RuntimeClassList";
31}
3233impl crate::Metadata for RuntimeClass {
34type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
3536fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
37&self.metadata
38 }
3940fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
41&mut self.metadata
42 }
43}
4445impl crate::DeepMerge for RuntimeClass {
46fn merge_from(&mut self, other: Self) {
47crate::DeepMerge::merge_from(&mut self.handler, other.handler);
48crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
49crate::DeepMerge::merge_from(&mut self.overhead, other.overhead);
50crate::DeepMerge::merge_from(&mut self.scheduling, other.scheduling);
51 }
52}
5354impl<'de> crate::serde::Deserialize<'de> for RuntimeClass {
55fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56#[allow(non_camel_case_types)]
57enum Field {
58 Key_api_version,
59 Key_kind,
60 Key_handler,
61 Key_metadata,
62 Key_overhead,
63 Key_scheduling,
64 Other,
65 }
6667impl<'de> crate::serde::Deserialize<'de> for Field {
68fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
69struct Visitor;
7071impl crate::serde::de::Visitor<'_> for Visitor {
72type Value = Field;
7374fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75 f.write_str("field identifier")
76 }
7778fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
79Ok(match v {
80"apiVersion" => Field::Key_api_version,
81"kind" => Field::Key_kind,
82"handler" => Field::Key_handler,
83"metadata" => Field::Key_metadata,
84"overhead" => Field::Key_overhead,
85"scheduling" => Field::Key_scheduling,
86_ => Field::Other,
87 })
88 }
89 }
9091 deserializer.deserialize_identifier(Visitor)
92 }
93 }
9495struct Visitor;
9697impl<'de> crate::serde::de::Visitor<'de> for Visitor {
98type Value = RuntimeClass;
99100fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
101 f.write_str(<Self::Value as crate::Resource>::KIND)
102 }
103104fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
105let mut value_handler: Option<std::string::String> = None;
106let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
107let mut value_overhead: Option<crate::api::node::v1::Overhead> = None;
108let mut value_scheduling: Option<crate::api::node::v1::Scheduling> = None;
109110while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
111match key {
112 Field::Key_api_version => {
113let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
114if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
115return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
116 }
117 },
118 Field::Key_kind => {
119let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
120if value_kind != <Self::Value as crate::Resource>::KIND {
121return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
122 }
123 },
124 Field::Key_handler => value_handler = crate::serde::de::MapAccess::next_value(&mut map)?,
125 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
126 Field::Key_overhead => value_overhead = crate::serde::de::MapAccess::next_value(&mut map)?,
127 Field::Key_scheduling => value_scheduling = crate::serde::de::MapAccess::next_value(&mut map)?,
128 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
129 }
130 }
131132Ok(RuntimeClass {
133 handler: value_handler.unwrap_or_default(),
134 metadata: value_metadata.unwrap_or_default(),
135 overhead: value_overhead,
136 scheduling: value_scheduling,
137 })
138 }
139 }
140141 deserializer.deserialize_struct(
142 <Self as crate::Resource>::KIND,
143&[
144"apiVersion",
145"kind",
146"handler",
147"metadata",
148"overhead",
149"scheduling",
150 ],
151 Visitor,
152 )
153 }
154}
155156impl crate::serde::Serialize for RuntimeClass {
157fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
158let mut state = serializer.serialize_struct(
159 <Self as crate::Resource>::KIND,
1604 +
161self.overhead.as_ref().map_or(0, |_| 1) +
162self.scheduling.as_ref().map_or(0, |_| 1),
163 )?;
164crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
165crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
166crate::serde::ser::SerializeStruct::serialize_field(&mut state, "handler", &self.handler)?;
167crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
168if let Some(value) = &self.overhead {
169crate::serde::ser::SerializeStruct::serialize_field(&mut state, "overhead", value)?;
170 }
171if let Some(value) = &self.scheduling {
172crate::serde::ser::SerializeStruct::serialize_field(&mut state, "scheduling", value)?;
173 }
174crate::serde::ser::SerializeStruct::end(state)
175 }
176}
177178#[cfg(feature = "schemars")]
179impl crate::schemars::JsonSchema for RuntimeClass {
180fn schema_name() -> std::string::String {
181"io.k8s.api.node.v1.RuntimeClass".into()
182 }
183184fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
185crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
186 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
187 description: Some("RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://kubernetes.io/docs/concepts/containers/runtime-class/".into()),
188 ..Default::default()
189 })),
190 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
191 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
192 properties: [
193 (
194"apiVersion".into(),
195crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
196 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
197 description: Some("APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources".into()),
198 ..Default::default()
199 })),
200 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
201 ..Default::default()
202 }),
203 ),
204 (
205"handler".into(),
206crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
207 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
208 description: Some("handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.".into()),
209 ..Default::default()
210 })),
211 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
212 ..Default::default()
213 }),
214 ),
215 (
216"kind".into(),
217crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
218 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
219 description: Some("Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".into()),
220 ..Default::default()
221 })),
222 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
223 ..Default::default()
224 }),
225 ),
226 (
227"metadata".into(),
228 {
229let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
230 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
231 description: Some("More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into()),
232 ..Default::default()
233 }));
234crate::schemars::schema::Schema::Object(schema_obj)
235 },
236 ),
237 (
238"overhead".into(),
239 {
240let mut schema_obj = __gen.subschema_for::<crate::api::node::v1::Overhead>().into_object();
241 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
242 description: Some("overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/".into()),
243 ..Default::default()
244 }));
245crate::schemars::schema::Schema::Object(schema_obj)
246 },
247 ),
248 (
249"scheduling".into(),
250 {
251let mut schema_obj = __gen.subschema_for::<crate::api::node::v1::Scheduling>().into_object();
252 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
253 description: Some("scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.".into()),
254 ..Default::default()
255 }));
256crate::schemars::schema::Schema::Object(schema_obj)
257 },
258 ),
259 ].into(),
260 required: [
261"handler".into(),
262"metadata".into(),
263 ].into(),
264 ..Default::default()
265 })),
266 ..Default::default()
267 })
268 }
269}