k8s_openapi/v1_34/api/certificates/v1alpha1/
cluster_trust_bundle.rs

1// Generated from definition io.k8s.api.certificates.v1alpha1.ClusterTrustBundle
2
3/// ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors (root certificates).
4///
5/// ClusterTrustBundle objects are considered to be readable by any authenticated user in the cluster, because they can be mounted by pods using the `clusterTrustBundle` projection.  All service accounts have read access to ClusterTrustBundles by default.  Users who only have namespace-level access to a cluster can read ClusterTrustBundles by impersonating a serviceaccount that they have access to.
6///
7/// It can be optionally associated with a particular assigner, in which case it contains one valid set of trust anchors for that signer. Signers may have multiple associated ClusterTrustBundles; each is an independent set of trust anchors for that signer. Admission control is used to enforce that only users with permissions on the signer can create or modify the corresponding bundle.
8#[derive(Clone, Debug, Default, PartialEq)]
9pub struct ClusterTrustBundle {
10    /// metadata contains the object metadata.
11    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
12
13    /// spec contains the signer (if any) and trust anchors.
14    pub spec: crate::api::certificates::v1alpha1::ClusterTrustBundleSpec,
15}
16
17impl crate::Resource for ClusterTrustBundle {
18    const API_VERSION: &'static str = "certificates.k8s.io/v1alpha1";
19    const GROUP: &'static str = "certificates.k8s.io";
20    const KIND: &'static str = "ClusterTrustBundle";
21    const VERSION: &'static str = "v1alpha1";
22    const URL_PATH_SEGMENT: &'static str = "clustertrustbundles";
23    type Scope = crate::ClusterResourceScope;
24}
25
26impl crate::ListableResource for ClusterTrustBundle {
27    const LIST_KIND: &'static str = "ClusterTrustBundleList";
28}
29
30impl crate::Metadata for ClusterTrustBundle {
31    type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
32
33    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
34        &self.metadata
35    }
36
37    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
38        &mut self.metadata
39    }
40}
41
42impl crate::DeepMerge for ClusterTrustBundle {
43    fn merge_from(&mut self, other: Self) {
44        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
45        crate::DeepMerge::merge_from(&mut self.spec, other.spec);
46    }
47}
48
49impl<'de> crate::serde::Deserialize<'de> for ClusterTrustBundle {
50    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
51        #[allow(non_camel_case_types)]
52        enum Field {
53            Key_api_version,
54            Key_kind,
55            Key_metadata,
56            Key_spec,
57            Other,
58        }
59
60        impl<'de> crate::serde::Deserialize<'de> for Field {
61            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
62                struct Visitor;
63
64                impl crate::serde::de::Visitor<'_> for Visitor {
65                    type Value = Field;
66
67                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
68                        f.write_str("field identifier")
69                    }
70
71                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
72                        Ok(match v {
73                            "apiVersion" => Field::Key_api_version,
74                            "kind" => Field::Key_kind,
75                            "metadata" => Field::Key_metadata,
76                            "spec" => Field::Key_spec,
77                            _ => Field::Other,
78                        })
79                    }
80                }
81
82                deserializer.deserialize_identifier(Visitor)
83            }
84        }
85
86        struct Visitor;
87
88        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
89            type Value = ClusterTrustBundle;
90
91            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
92                f.write_str(<Self::Value as crate::Resource>::KIND)
93            }
94
95            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
96                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
97                let mut value_spec: Option<crate::api::certificates::v1alpha1::ClusterTrustBundleSpec> = None;
98
99                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
100                    match key {
101                        Field::Key_api_version => {
102                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
103                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
104                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
105                            }
106                        },
107                        Field::Key_kind => {
108                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
109                            if value_kind != <Self::Value as crate::Resource>::KIND {
110                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
111                            }
112                        },
113                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
114                        Field::Key_spec => value_spec = crate::serde::de::MapAccess::next_value(&mut map)?,
115                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
116                    }
117                }
118
119                Ok(ClusterTrustBundle {
120                    metadata: value_metadata.unwrap_or_default(),
121                    spec: value_spec.unwrap_or_default(),
122                })
123            }
124        }
125
126        deserializer.deserialize_struct(
127            <Self as crate::Resource>::KIND,
128            &[
129                "apiVersion",
130                "kind",
131                "metadata",
132                "spec",
133            ],
134            Visitor,
135        )
136    }
137}
138
139impl crate::serde::Serialize for ClusterTrustBundle {
140    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
141        let mut state = serializer.serialize_struct(
142            <Self as crate::Resource>::KIND,
143            4,
144        )?;
145        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
146        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
147        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
148        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "spec", &self.spec)?;
149        crate::serde::ser::SerializeStruct::end(state)
150    }
151}
152
153#[cfg(feature = "schemars")]
154impl crate::schemars::JsonSchema for ClusterTrustBundle {
155    fn schema_name() -> std::borrow::Cow<'static, str> {
156        "io.k8s.api.certificates.v1alpha1.ClusterTrustBundle".into()
157    }
158
159    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
160        crate::schemars::json_schema!({
161            "description": "ClusterTrustBundle is a cluster-scoped container for X.509 trust anchors (root certificates).\n\nClusterTrustBundle objects are considered to be readable by any authenticated user in the cluster, because they can be mounted by pods using the `clusterTrustBundle` projection.  All service accounts have read access to ClusterTrustBundles by default.  Users who only have namespace-level access to a cluster can read ClusterTrustBundles by impersonating a serviceaccount that they have access to.\n\nIt can be optionally associated with a particular assigner, in which case it contains one valid set of trust anchors for that signer. Signers may have multiple associated ClusterTrustBundles; each is an independent set of trust anchors for that signer. Admission control is used to enforce that only users with permissions on the signer can create or modify the corresponding bundle.",
162            "type": "object",
163            "properties": {
164                "apiVersion": {
165                    "description": "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",
166                    "type": "string",
167                },
168                "kind": {
169                    "description": "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",
170                    "type": "string",
171                },
172                "metadata": ({
173                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
174                    schema_obj.ensure_object().insert("description".into(), "metadata contains the object metadata.".into());
175                    schema_obj
176                }),
177                "spec": ({
178                    let mut schema_obj = __gen.subschema_for::<crate::api::certificates::v1alpha1::ClusterTrustBundleSpec>();
179                    schema_obj.ensure_object().insert("description".into(), "spec contains the signer (if any) and trust anchors.".into());
180                    schema_obj
181                }),
182            },
183            "required": [
184                "metadata",
185                "spec",
186            ],
187        })
188    }
189}