1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodCertificateRequestSpec {
6 pub max_expiration_seconds: Option<i32>,
12
13 pub node_name: std::string::String,
15
16 pub node_uid: std::string::String,
18
19 pub pkix_public_key: crate::ByteString,
25
26 pub pod_name: std::string::String,
28
29 pub pod_uid: std::string::String,
31
32 pub proof_of_possession: crate::ByteString,
44
45 pub service_account_name: std::string::String,
47
48 pub service_account_uid: std::string::String,
50
51 pub signer_name: std::string::String,
55
56 pub unverified_user_annotations: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
62}
63
64impl crate::DeepMerge for PodCertificateRequestSpec {
65 fn merge_from(&mut self, other: Self) {
66 crate::DeepMerge::merge_from(&mut self.max_expiration_seconds, other.max_expiration_seconds);
67 crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
68 crate::DeepMerge::merge_from(&mut self.node_uid, other.node_uid);
69 crate::DeepMerge::merge_from(&mut self.pkix_public_key, other.pkix_public_key);
70 crate::DeepMerge::merge_from(&mut self.pod_name, other.pod_name);
71 crate::DeepMerge::merge_from(&mut self.pod_uid, other.pod_uid);
72 crate::DeepMerge::merge_from(&mut self.proof_of_possession, other.proof_of_possession);
73 crate::DeepMerge::merge_from(&mut self.service_account_name, other.service_account_name);
74 crate::DeepMerge::merge_from(&mut self.service_account_uid, other.service_account_uid);
75 crate::DeepMerge::merge_from(&mut self.signer_name, other.signer_name);
76 crate::merge_strategies::map::granular(&mut self.unverified_user_annotations, other.unverified_user_annotations, |current_item, other_item| {
77 crate::DeepMerge::merge_from(current_item, other_item);
78 });
79 }
80}
81
82impl<'de> crate::serde::Deserialize<'de> for PodCertificateRequestSpec {
83 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
84 #[allow(non_camel_case_types)]
85 enum Field {
86 Key_max_expiration_seconds,
87 Key_node_name,
88 Key_node_uid,
89 Key_pkix_public_key,
90 Key_pod_name,
91 Key_pod_uid,
92 Key_proof_of_possession,
93 Key_service_account_name,
94 Key_service_account_uid,
95 Key_signer_name,
96 Key_unverified_user_annotations,
97 Other,
98 }
99
100 impl<'de> crate::serde::Deserialize<'de> for Field {
101 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
102 struct Visitor;
103
104 impl crate::serde::de::Visitor<'_> for Visitor {
105 type Value = Field;
106
107 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
108 f.write_str("field identifier")
109 }
110
111 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
112 Ok(match v {
113 "maxExpirationSeconds" => Field::Key_max_expiration_seconds,
114 "nodeName" => Field::Key_node_name,
115 "nodeUID" => Field::Key_node_uid,
116 "pkixPublicKey" => Field::Key_pkix_public_key,
117 "podName" => Field::Key_pod_name,
118 "podUID" => Field::Key_pod_uid,
119 "proofOfPossession" => Field::Key_proof_of_possession,
120 "serviceAccountName" => Field::Key_service_account_name,
121 "serviceAccountUID" => Field::Key_service_account_uid,
122 "signerName" => Field::Key_signer_name,
123 "unverifiedUserAnnotations" => Field::Key_unverified_user_annotations,
124 _ => Field::Other,
125 })
126 }
127 }
128
129 deserializer.deserialize_identifier(Visitor)
130 }
131 }
132
133 struct Visitor;
134
135 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
136 type Value = PodCertificateRequestSpec;
137
138 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
139 f.write_str("PodCertificateRequestSpec")
140 }
141
142 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
143 let mut value_max_expiration_seconds: Option<i32> = None;
144 let mut value_node_name: Option<std::string::String> = None;
145 let mut value_node_uid: Option<std::string::String> = None;
146 let mut value_pkix_public_key: Option<crate::ByteString> = None;
147 let mut value_pod_name: Option<std::string::String> = None;
148 let mut value_pod_uid: Option<std::string::String> = None;
149 let mut value_proof_of_possession: Option<crate::ByteString> = None;
150 let mut value_service_account_name: Option<std::string::String> = None;
151 let mut value_service_account_uid: Option<std::string::String> = None;
152 let mut value_signer_name: Option<std::string::String> = None;
153 let mut value_unverified_user_annotations: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
154
155 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
156 match key {
157 Field::Key_max_expiration_seconds => value_max_expiration_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
158 Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
159 Field::Key_node_uid => value_node_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
160 Field::Key_pkix_public_key => value_pkix_public_key = crate::serde::de::MapAccess::next_value(&mut map)?,
161 Field::Key_pod_name => value_pod_name = crate::serde::de::MapAccess::next_value(&mut map)?,
162 Field::Key_pod_uid => value_pod_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
163 Field::Key_proof_of_possession => value_proof_of_possession = crate::serde::de::MapAccess::next_value(&mut map)?,
164 Field::Key_service_account_name => value_service_account_name = crate::serde::de::MapAccess::next_value(&mut map)?,
165 Field::Key_service_account_uid => value_service_account_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
166 Field::Key_signer_name => value_signer_name = crate::serde::de::MapAccess::next_value(&mut map)?,
167 Field::Key_unverified_user_annotations => value_unverified_user_annotations = crate::serde::de::MapAccess::next_value(&mut map)?,
168 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
169 }
170 }
171
172 Ok(PodCertificateRequestSpec {
173 max_expiration_seconds: value_max_expiration_seconds,
174 node_name: value_node_name.unwrap_or_default(),
175 node_uid: value_node_uid.unwrap_or_default(),
176 pkix_public_key: value_pkix_public_key.unwrap_or_default(),
177 pod_name: value_pod_name.unwrap_or_default(),
178 pod_uid: value_pod_uid.unwrap_or_default(),
179 proof_of_possession: value_proof_of_possession.unwrap_or_default(),
180 service_account_name: value_service_account_name.unwrap_or_default(),
181 service_account_uid: value_service_account_uid.unwrap_or_default(),
182 signer_name: value_signer_name.unwrap_or_default(),
183 unverified_user_annotations: value_unverified_user_annotations,
184 })
185 }
186 }
187
188 deserializer.deserialize_struct(
189 "PodCertificateRequestSpec",
190 &[
191 "maxExpirationSeconds",
192 "nodeName",
193 "nodeUID",
194 "pkixPublicKey",
195 "podName",
196 "podUID",
197 "proofOfPossession",
198 "serviceAccountName",
199 "serviceAccountUID",
200 "signerName",
201 "unverifiedUserAnnotations",
202 ],
203 Visitor,
204 )
205 }
206}
207
208impl crate::serde::Serialize for PodCertificateRequestSpec {
209 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
210 let mut state = serializer.serialize_struct(
211 "PodCertificateRequestSpec",
212 9 +
213 self.max_expiration_seconds.as_ref().map_or(0, |_| 1) +
214 self.unverified_user_annotations.as_ref().map_or(0, |_| 1),
215 )?;
216 if let Some(value) = &self.max_expiration_seconds {
217 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "maxExpirationSeconds", value)?;
218 }
219 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", &self.node_name)?;
220 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeUID", &self.node_uid)?;
221 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pkixPublicKey", &self.pkix_public_key)?;
222 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podName", &self.pod_name)?;
223 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podUID", &self.pod_uid)?;
224 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "proofOfPossession", &self.proof_of_possession)?;
225 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountName", &self.service_account_name)?;
226 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountUID", &self.service_account_uid)?;
227 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "signerName", &self.signer_name)?;
228 if let Some(value) = &self.unverified_user_annotations {
229 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unverifiedUserAnnotations", value)?;
230 }
231 crate::serde::ser::SerializeStruct::end(state)
232 }
233}
234
235#[cfg(feature = "schemars")]
236impl crate::schemars::JsonSchema for PodCertificateRequestSpec {
237 fn schema_name() -> std::borrow::Cow<'static, str> {
238 "io.k8s.api.certificates.v1beta1.PodCertificateRequestSpec".into()
239 }
240
241 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
242 crate::schemars::json_schema!({
243 "description": "PodCertificateRequestSpec describes the certificate request. All fields are immutable after creation.",
244 "type": "object",
245 "properties": {
246 "maxExpirationSeconds": {
247 "description": "maxExpirationSeconds is the maximum lifetime permitted for the certificate.\n\nIf omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour). The maximum allowable value is 7862400 (91 days).\n\nThe signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour). This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours.",
248 "type": "integer",
249 "format": "int32",
250 },
251 "nodeName": {
252 "description": "nodeName is the name of the node the pod is assigned to.",
253 "type": "string",
254 },
255 "nodeUID": {
256 "description": "nodeUID is the UID of the node the pod is assigned to.",
257 "type": "string",
258 },
259 "pkixPublicKey": {
260 "description": "pkixPublicKey is the PKIX-serialized public key the signer will issue the certificate to.\n\nThe key must be one of RSA3072, RSA4096, ECDSAP256, ECDSAP384, ECDSAP521, or ED25519. Note that this list may be expanded in the future.\n\nSigner implementations do not need to support all key types supported by kube-apiserver and kubelet. If a signer does not support the key type used for a given PodCertificateRequest, it must deny the request by setting a status.conditions entry with a type of \"Denied\" and a reason of \"UnsupportedKeyType\". It may also suggest a key type that it does support in the message field.",
261 "type": "string",
262 "format": "byte",
263 },
264 "podName": {
265 "description": "podName is the name of the pod into which the certificate will be mounted.",
266 "type": "string",
267 },
268 "podUID": {
269 "description": "podUID is the UID of the pod into which the certificate will be mounted.",
270 "type": "string",
271 },
272 "proofOfPossession": {
273 "description": "proofOfPossession proves that the requesting kubelet holds the private key corresponding to pkixPublicKey.\n\nIt is contructed by signing the ASCII bytes of the pod's UID using `pkixPublicKey`.\n\nkube-apiserver validates the proof of possession during creation of the PodCertificateRequest.\n\nIf the key is an RSA key, then the signature is over the ASCII bytes of the pod UID, using RSASSA-PSS from RFC 8017 (as implemented by the golang function crypto/rsa.SignPSS with nil options).\n\nIf the key is an ECDSA key, then the signature is as described by [SEC 1, Version 2.0](https://www.secg.org/sec1-v2.pdf) (as implemented by the golang library function crypto/ecdsa.SignASN1)\n\nIf the key is an ED25519 key, the the signature is as described by the [ED25519 Specification](https://ed25519.cr.yp.to/) (as implemented by the golang library crypto/ed25519.Sign).",
274 "type": "string",
275 "format": "byte",
276 },
277 "serviceAccountName": {
278 "description": "serviceAccountName is the name of the service account the pod is running as.",
279 "type": "string",
280 },
281 "serviceAccountUID": {
282 "description": "serviceAccountUID is the UID of the service account the pod is running as.",
283 "type": "string",
284 },
285 "signerName": {
286 "description": "signerName indicates the requested signer.\n\nAll signer names beginning with `kubernetes.io` are reserved for use by the Kubernetes project. There is currently one well-known signer documented by the Kubernetes project, `kubernetes.io/kube-apiserver-client-pod`, which will issue client certificates understood by kube-apiserver. It is currently unimplemented.",
287 "type": "string",
288 },
289 "unverifiedUserAnnotations": {
290 "description": "unverifiedUserAnnotations allow pod authors to pass additional information to the signer implementation. Kubernetes does not restrict or validate this metadata in any way.\n\nEntries are subject to the same validation as object metadata annotations, with the addition that all keys must be domain-prefixed. No restrictions are placed on values, except an overall size limitation on the entire field.\n\nSigners should document the keys and values they support. Signers should deny requests that contain keys they do not recognize.",
291 "type": "object",
292 "additionalProperties": {
293 "type": "string",
294 },
295 },
296 },
297 "required": [
298 "nodeName",
299 "nodeUID",
300 "pkixPublicKey",
301 "podName",
302 "podUID",
303 "proofOfPossession",
304 "serviceAccountName",
305 "serviceAccountUID",
306 "signerName",
307 ],
308 })
309 }
310}