Skip to main content

k8s_openapi/v1_37/api/certificates/v1/
pod_certificate_request_spec.rs

1// Generated from definition io.k8s.api.certificates.v1.PodCertificateRequestSpec
2
3/// PodCertificateRequestSpec describes the certificate request.  All fields are immutable after creation.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodCertificateRequestSpec {
6    /// maxExpirationSeconds is the maximum lifetime permitted for the certificate.
7    ///
8    /// If 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).
9    ///
10    /// The 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.
11    pub max_expiration_seconds: Option<i32>,
12
13    /// nodeName is the name of the node the pod is assigned to.
14    pub node_name: std::string::String,
15
16    /// nodeUID is the UID of the node the pod is assigned to.
17    pub node_uid: std::string::String,
18
19    /// podName is the name of the pod into which the certificate will be mounted.
20    pub pod_name: std::string::String,
21
22    /// podUID is the UID of the pod into which the certificate will be mounted.
23    pub pod_uid: std::string::String,
24
25    /// serviceAccountName is the name of the service account the pod is running as.
26    pub service_account_name: std::string::String,
27
28    /// serviceAccountUID is the UID of the service account the pod is running as.
29    pub service_account_uid: std::string::String,
30
31    /// signerName indicates the requested signer.
32    ///
33    /// All 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.
34    pub signer_name: std::string::String,
35
36    /// A PKCS#10 certificate signing request (DER-serialized) generated by Kubelet using the subject private key.
37    ///
38    /// Most signer implementations will ignore the contents of the CSR except to extract the subject public key. The API server automatically verifies the CSR signature during admission, so the signer does not need to repeat the verification.  CSRs generated by kubelet are completely empty.
39    ///
40    /// The subject public key must be one of RSA3072, RSA4096, ECDSAP256, ECDSAP384, ECDSAP521, or ED25519. Note that this list may be expanded in the future.
41    ///
42    /// Signer 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.
43    pub stub_pkc_s10_request: crate::ByteString,
44
45    /// unverifiedUserAnnotations allow pod authors to pass additional information to the signer implementation.  Kubernetes does not restrict or validate this metadata in any way.
46    ///
47    /// Entries 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.
48    ///
49    /// Signers should document the keys and values they support.  Signers should deny requests that contain keys they do not recognize.
50    pub unverified_user_annotations: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
51}
52
53impl crate::DeepMerge for PodCertificateRequestSpec {
54    fn merge_from(&mut self, other: Self) {
55        crate::DeepMerge::merge_from(&mut self.max_expiration_seconds, other.max_expiration_seconds);
56        crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
57        crate::DeepMerge::merge_from(&mut self.node_uid, other.node_uid);
58        crate::DeepMerge::merge_from(&mut self.pod_name, other.pod_name);
59        crate::DeepMerge::merge_from(&mut self.pod_uid, other.pod_uid);
60        crate::DeepMerge::merge_from(&mut self.service_account_name, other.service_account_name);
61        crate::DeepMerge::merge_from(&mut self.service_account_uid, other.service_account_uid);
62        crate::DeepMerge::merge_from(&mut self.signer_name, other.signer_name);
63        crate::DeepMerge::merge_from(&mut self.stub_pkc_s10_request, other.stub_pkc_s10_request);
64        crate::merge_strategies::map::granular(&mut self.unverified_user_annotations, other.unverified_user_annotations, |current_item, other_item| {
65            crate::DeepMerge::merge_from(current_item, other_item);
66        });
67    }
68}
69
70impl<'de> crate::serde::Deserialize<'de> for PodCertificateRequestSpec {
71    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
72        #[allow(non_camel_case_types)]
73        enum Field {
74            Key_max_expiration_seconds,
75            Key_node_name,
76            Key_node_uid,
77            Key_pod_name,
78            Key_pod_uid,
79            Key_service_account_name,
80            Key_service_account_uid,
81            Key_signer_name,
82            Key_stub_pkc_s10_request,
83            Key_unverified_user_annotations,
84            Other,
85        }
86
87        impl<'de> crate::serde::Deserialize<'de> for Field {
88            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
89                struct Visitor;
90
91                impl crate::serde::de::Visitor<'_> for Visitor {
92                    type Value = Field;
93
94                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95                        f.write_str("field identifier")
96                    }
97
98                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
99                        Ok(match v {
100                            "maxExpirationSeconds" => Field::Key_max_expiration_seconds,
101                            "nodeName" => Field::Key_node_name,
102                            "nodeUID" => Field::Key_node_uid,
103                            "podName" => Field::Key_pod_name,
104                            "podUID" => Field::Key_pod_uid,
105                            "serviceAccountName" => Field::Key_service_account_name,
106                            "serviceAccountUID" => Field::Key_service_account_uid,
107                            "signerName" => Field::Key_signer_name,
108                            "stubPKCS10Request" => Field::Key_stub_pkc_s10_request,
109                            "unverifiedUserAnnotations" => Field::Key_unverified_user_annotations,
110                            _ => Field::Other,
111                        })
112                    }
113                }
114
115                deserializer.deserialize_identifier(Visitor)
116            }
117        }
118
119        struct Visitor;
120
121        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
122            type Value = PodCertificateRequestSpec;
123
124            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
125                f.write_str("PodCertificateRequestSpec")
126            }
127
128            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
129                let mut value_max_expiration_seconds: Option<i32> = None;
130                let mut value_node_name: Option<std::string::String> = None;
131                let mut value_node_uid: Option<std::string::String> = None;
132                let mut value_pod_name: Option<std::string::String> = None;
133                let mut value_pod_uid: Option<std::string::String> = None;
134                let mut value_service_account_name: Option<std::string::String> = None;
135                let mut value_service_account_uid: Option<std::string::String> = None;
136                let mut value_signer_name: Option<std::string::String> = None;
137                let mut value_stub_pkc_s10_request: Option<crate::ByteString> = None;
138                let mut value_unverified_user_annotations: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
139
140                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
141                    match key {
142                        Field::Key_max_expiration_seconds => value_max_expiration_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
143                        Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
144                        Field::Key_node_uid => value_node_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
145                        Field::Key_pod_name => value_pod_name = crate::serde::de::MapAccess::next_value(&mut map)?,
146                        Field::Key_pod_uid => value_pod_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
147                        Field::Key_service_account_name => value_service_account_name = crate::serde::de::MapAccess::next_value(&mut map)?,
148                        Field::Key_service_account_uid => value_service_account_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
149                        Field::Key_signer_name => value_signer_name = crate::serde::de::MapAccess::next_value(&mut map)?,
150                        Field::Key_stub_pkc_s10_request => value_stub_pkc_s10_request = crate::serde::de::MapAccess::next_value(&mut map)?,
151                        Field::Key_unverified_user_annotations => value_unverified_user_annotations = crate::serde::de::MapAccess::next_value(&mut map)?,
152                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
153                    }
154                }
155
156                Ok(PodCertificateRequestSpec {
157                    max_expiration_seconds: value_max_expiration_seconds,
158                    node_name: value_node_name.unwrap_or_default(),
159                    node_uid: value_node_uid.unwrap_or_default(),
160                    pod_name: value_pod_name.unwrap_or_default(),
161                    pod_uid: value_pod_uid.unwrap_or_default(),
162                    service_account_name: value_service_account_name.unwrap_or_default(),
163                    service_account_uid: value_service_account_uid.unwrap_or_default(),
164                    signer_name: value_signer_name.unwrap_or_default(),
165                    stub_pkc_s10_request: value_stub_pkc_s10_request.unwrap_or_default(),
166                    unverified_user_annotations: value_unverified_user_annotations,
167                })
168            }
169        }
170
171        deserializer.deserialize_struct(
172            "PodCertificateRequestSpec",
173            &[
174                "maxExpirationSeconds",
175                "nodeName",
176                "nodeUID",
177                "podName",
178                "podUID",
179                "serviceAccountName",
180                "serviceAccountUID",
181                "signerName",
182                "stubPKCS10Request",
183                "unverifiedUserAnnotations",
184            ],
185            Visitor,
186        )
187    }
188}
189
190impl crate::serde::Serialize for PodCertificateRequestSpec {
191    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
192        let mut state = serializer.serialize_struct(
193            "PodCertificateRequestSpec",
194            8 +
195            self.max_expiration_seconds.as_ref().map_or(0, |_| 1) +
196            self.unverified_user_annotations.as_ref().map_or(0, |_| 1),
197        )?;
198        if let Some(value) = &self.max_expiration_seconds {
199            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "maxExpirationSeconds", value)?;
200        }
201        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", &self.node_name)?;
202        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeUID", &self.node_uid)?;
203        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podName", &self.pod_name)?;
204        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podUID", &self.pod_uid)?;
205        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountName", &self.service_account_name)?;
206        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountUID", &self.service_account_uid)?;
207        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "signerName", &self.signer_name)?;
208        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stubPKCS10Request", &self.stub_pkc_s10_request)?;
209        if let Some(value) = &self.unverified_user_annotations {
210            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unverifiedUserAnnotations", value)?;
211        }
212        crate::serde::ser::SerializeStruct::end(state)
213    }
214}
215
216#[cfg(feature = "schemars")]
217impl crate::schemars::JsonSchema for PodCertificateRequestSpec {
218    fn schema_name() -> std::borrow::Cow<'static, str> {
219        "io.k8s.api.certificates.v1.PodCertificateRequestSpec".into()
220    }
221
222    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
223        crate::schemars::json_schema!({
224            "description": "PodCertificateRequestSpec describes the certificate request.  All fields are immutable after creation.",
225            "type": "object",
226            "properties": {
227                "maxExpirationSeconds": {
228                    "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.",
229                    "type": "integer",
230                    "format": "int32",
231                },
232                "nodeName": {
233                    "description": "nodeName is the name of the node the pod is assigned to.",
234                    "type": "string",
235                },
236                "nodeUID": {
237                    "description": "nodeUID is the UID of the node the pod is assigned to.",
238                    "type": "string",
239                },
240                "podName": {
241                    "description": "podName is the name of the pod into which the certificate will be mounted.",
242                    "type": "string",
243                },
244                "podUID": {
245                    "description": "podUID is the UID of the pod into which the certificate will be mounted.",
246                    "type": "string",
247                },
248                "serviceAccountName": {
249                    "description": "serviceAccountName is the name of the service account the pod is running as.",
250                    "type": "string",
251                },
252                "serviceAccountUID": {
253                    "description": "serviceAccountUID is the UID of the service account the pod is running as.",
254                    "type": "string",
255                },
256                "signerName": {
257                    "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.",
258                    "type": "string",
259                },
260                "stubPKCS10Request": {
261                    "description": "A PKCS#10 certificate signing request (DER-serialized) generated by Kubelet using the subject private key.\n\nMost signer implementations will ignore the contents of the CSR except to extract the subject public key. The API server automatically verifies the CSR signature during admission, so the signer does not need to repeat the verification.  CSRs generated by kubelet are completely empty.\n\nThe subject public 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.",
262                    "type": "string",
263                    "format": "byte",
264                },
265                "unverifiedUserAnnotations": {
266                    "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.",
267                    "type": "object",
268                    "additionalProperties": {
269                        "type": "string",
270                    },
271                },
272            },
273            "required": [
274                "nodeName",
275                "nodeUID",
276                "podName",
277                "podUID",
278                "serviceAccountName",
279                "serviceAccountUID",
280                "signerName",
281                "stubPKCS10Request",
282            ],
283        })
284    }
285}