k8s_openapi/v1_35/api/core/v1/
config_map_node_config_source.rs

1// Generated from definition io.k8s.api.core.v1.ConfigMapNodeConfigSource
2
3/// ConfigMapNodeConfigSource contains the information to reference a ConfigMap as a config source for the Node. This API is deprecated since 1.22: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ConfigMapNodeConfigSource {
6    /// KubeletConfigKey declares which key of the referenced ConfigMap corresponds to the KubeletConfiguration structure This field is required in all cases.
7    pub kubelet_config_key: std::string::String,
8
9    /// Name is the metadata.name of the referenced ConfigMap. This field is required in all cases.
10    pub name: std::string::String,
11
12    /// Namespace is the metadata.namespace of the referenced ConfigMap. This field is required in all cases.
13    pub namespace: std::string::String,
14
15    /// ResourceVersion is the metadata.ResourceVersion of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.
16    pub resource_version: Option<std::string::String>,
17
18    /// UID is the metadata.UID of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.
19    pub uid: Option<std::string::String>,
20}
21
22impl crate::DeepMerge for ConfigMapNodeConfigSource {
23    fn merge_from(&mut self, other: Self) {
24        crate::DeepMerge::merge_from(&mut self.kubelet_config_key, other.kubelet_config_key);
25        crate::DeepMerge::merge_from(&mut self.name, other.name);
26        crate::DeepMerge::merge_from(&mut self.namespace, other.namespace);
27        crate::DeepMerge::merge_from(&mut self.resource_version, other.resource_version);
28        crate::DeepMerge::merge_from(&mut self.uid, other.uid);
29    }
30}
31
32impl<'de> crate::serde::Deserialize<'de> for ConfigMapNodeConfigSource {
33    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34        #[allow(non_camel_case_types)]
35        enum Field {
36            Key_kubelet_config_key,
37            Key_name,
38            Key_namespace,
39            Key_resource_version,
40            Key_uid,
41            Other,
42        }
43
44        impl<'de> crate::serde::Deserialize<'de> for Field {
45            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46                struct Visitor;
47
48                impl crate::serde::de::Visitor<'_> for Visitor {
49                    type Value = Field;
50
51                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52                        f.write_str("field identifier")
53                    }
54
55                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
56                        Ok(match v {
57                            "kubeletConfigKey" => Field::Key_kubelet_config_key,
58                            "name" => Field::Key_name,
59                            "namespace" => Field::Key_namespace,
60                            "resourceVersion" => Field::Key_resource_version,
61                            "uid" => Field::Key_uid,
62                            _ => Field::Other,
63                        })
64                    }
65                }
66
67                deserializer.deserialize_identifier(Visitor)
68            }
69        }
70
71        struct Visitor;
72
73        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74            type Value = ConfigMapNodeConfigSource;
75
76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                f.write_str("ConfigMapNodeConfigSource")
78            }
79
80            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81                let mut value_kubelet_config_key: Option<std::string::String> = None;
82                let mut value_name: Option<std::string::String> = None;
83                let mut value_namespace: Option<std::string::String> = None;
84                let mut value_resource_version: Option<std::string::String> = None;
85                let mut value_uid: Option<std::string::String> = None;
86
87                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
88                    match key {
89                        Field::Key_kubelet_config_key => value_kubelet_config_key = crate::serde::de::MapAccess::next_value(&mut map)?,
90                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
91                        Field::Key_namespace => value_namespace = crate::serde::de::MapAccess::next_value(&mut map)?,
92                        Field::Key_resource_version => value_resource_version = crate::serde::de::MapAccess::next_value(&mut map)?,
93                        Field::Key_uid => value_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
94                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
95                    }
96                }
97
98                Ok(ConfigMapNodeConfigSource {
99                    kubelet_config_key: value_kubelet_config_key.unwrap_or_default(),
100                    name: value_name.unwrap_or_default(),
101                    namespace: value_namespace.unwrap_or_default(),
102                    resource_version: value_resource_version,
103                    uid: value_uid,
104                })
105            }
106        }
107
108        deserializer.deserialize_struct(
109            "ConfigMapNodeConfigSource",
110            &[
111                "kubeletConfigKey",
112                "name",
113                "namespace",
114                "resourceVersion",
115                "uid",
116            ],
117            Visitor,
118        )
119    }
120}
121
122impl crate::serde::Serialize for ConfigMapNodeConfigSource {
123    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
124        let mut state = serializer.serialize_struct(
125            "ConfigMapNodeConfigSource",
126            3 +
127            self.resource_version.as_ref().map_or(0, |_| 1) +
128            self.uid.as_ref().map_or(0, |_| 1),
129        )?;
130        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kubeletConfigKey", &self.kubelet_config_key)?;
131        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
132        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "namespace", &self.namespace)?;
133        if let Some(value) = &self.resource_version {
134            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceVersion", value)?;
135        }
136        if let Some(value) = &self.uid {
137            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uid", value)?;
138        }
139        crate::serde::ser::SerializeStruct::end(state)
140    }
141}
142
143#[cfg(feature = "schemars")]
144impl crate::schemars::JsonSchema for ConfigMapNodeConfigSource {
145    fn schema_name() -> std::borrow::Cow<'static, str> {
146        "io.k8s.api.core.v1.ConfigMapNodeConfigSource".into()
147    }
148
149    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
150        crate::schemars::json_schema!({
151            "description": "ConfigMapNodeConfigSource contains the information to reference a ConfigMap as a config source for the Node. This API is deprecated since 1.22: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration",
152            "type": "object",
153            "properties": {
154                "kubeletConfigKey": {
155                    "description": "KubeletConfigKey declares which key of the referenced ConfigMap corresponds to the KubeletConfiguration structure This field is required in all cases.",
156                    "type": "string",
157                },
158                "name": {
159                    "description": "Name is the metadata.name of the referenced ConfigMap. This field is required in all cases.",
160                    "type": "string",
161                },
162                "namespace": {
163                    "description": "Namespace is the metadata.namespace of the referenced ConfigMap. This field is required in all cases.",
164                    "type": "string",
165                },
166                "resourceVersion": {
167                    "description": "ResourceVersion is the metadata.ResourceVersion of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.",
168                    "type": "string",
169                },
170                "uid": {
171                    "description": "UID is the metadata.UID of the referenced ConfigMap. This field is forbidden in Node.Spec, and required in Node.Status.",
172                    "type": "string",
173                },
174            },
175            "required": [
176                "kubeletConfigKey",
177                "name",
178                "namespace",
179            ],
180        })
181    }
182}