Skip to main content

k8s_openapi/v1_36/api/admissionregistration/v1/
webhook_client_config.rs

1// Generated from definition io.k8s.api.admissionregistration.v1.WebhookClientConfig
2
3/// WebhookClientConfig contains the information to make a TLS connection with the webhook
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct WebhookClientConfig {
6    /// caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used.
7    pub ca_bundle: Option<crate::ByteString>,
8
9    /// service is a reference to the service for this webhook. Either `service` or `url` must be specified.
10    ///
11    /// If the webhook is running within the cluster, then you should use `service`.
12    pub service: Option<crate::api::admissionregistration::v1::ServiceReference>,
13
14    /// url gives the location of the webhook, in standard URL form (`scheme://host:port/path`). Exactly one of `url` or `service` must be specified.
15    ///
16    /// The `host` should not refer to a service running in the cluster; use the `service` field instead. The host might be resolved via external DNS in some apiservers (e.g., `kube-apiserver` cannot resolve in-cluster DNS as that would be a layering violation). `host` may also be an IP address.
17    ///
18    /// Please note that using `localhost` or `127.0.0.1` as a `host` is risky unless you take great care to run this webhook on all hosts which run an apiserver which might need to make calls to this webhook. Such installs are likely to be non-portable, i.e., not easy to turn up in a new cluster.
19    ///
20    /// The scheme must be "https"; the URL must begin with "https://".
21    ///
22    /// A path is optional, and if present may be any string permissible in a URL. You may use the path to pass an arbitrary string to the webhook, for example, a cluster identifier.
23    ///
24    /// Attempting to use a user or basic auth e.g. "user:password@" is not allowed. Fragments ("#...") and query parameters ("?...") are not allowed, either.
25    pub url: Option<std::string::String>,
26}
27
28impl crate::DeepMerge for WebhookClientConfig {
29    fn merge_from(&mut self, other: Self) {
30        crate::DeepMerge::merge_from(&mut self.ca_bundle, other.ca_bundle);
31        crate::DeepMerge::merge_from(&mut self.service, other.service);
32        crate::DeepMerge::merge_from(&mut self.url, other.url);
33    }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for WebhookClientConfig {
37    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38        #[allow(non_camel_case_types)]
39        enum Field {
40            Key_ca_bundle,
41            Key_service,
42            Key_url,
43            Other,
44        }
45
46        impl<'de> crate::serde::Deserialize<'de> for Field {
47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48                struct Visitor;
49
50                impl crate::serde::de::Visitor<'_> for Visitor {
51                    type Value = Field;
52
53                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
54                        f.write_str("field identifier")
55                    }
56
57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
58                        Ok(match v {
59                            "caBundle" => Field::Key_ca_bundle,
60                            "service" => Field::Key_service,
61                            "url" => Field::Key_url,
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 = WebhookClientConfig;
75
76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                f.write_str("WebhookClientConfig")
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_ca_bundle: Option<crate::ByteString> = None;
82                let mut value_service: Option<crate::api::admissionregistration::v1::ServiceReference> = None;
83                let mut value_url: Option<std::string::String> = None;
84
85                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
86                    match key {
87                        Field::Key_ca_bundle => value_ca_bundle = crate::serde::de::MapAccess::next_value(&mut map)?,
88                        Field::Key_service => value_service = crate::serde::de::MapAccess::next_value(&mut map)?,
89                        Field::Key_url => value_url = crate::serde::de::MapAccess::next_value(&mut map)?,
90                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
91                    }
92                }
93
94                Ok(WebhookClientConfig {
95                    ca_bundle: value_ca_bundle,
96                    service: value_service,
97                    url: value_url,
98                })
99            }
100        }
101
102        deserializer.deserialize_struct(
103            "WebhookClientConfig",
104            &[
105                "caBundle",
106                "service",
107                "url",
108            ],
109            Visitor,
110        )
111    }
112}
113
114impl crate::serde::Serialize for WebhookClientConfig {
115    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116        let mut state = serializer.serialize_struct(
117            "WebhookClientConfig",
118            self.ca_bundle.as_ref().map_or(0, |_| 1) +
119            self.service.as_ref().map_or(0, |_| 1) +
120            self.url.as_ref().map_or(0, |_| 1),
121        )?;
122        if let Some(value) = &self.ca_bundle {
123            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "caBundle", value)?;
124        }
125        if let Some(value) = &self.service {
126            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "service", value)?;
127        }
128        if let Some(value) = &self.url {
129            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "url", value)?;
130        }
131        crate::serde::ser::SerializeStruct::end(state)
132    }
133}
134
135#[cfg(feature = "schemars")]
136impl crate::schemars::JsonSchema for WebhookClientConfig {
137    fn schema_name() -> std::borrow::Cow<'static, str> {
138        "io.k8s.api.admissionregistration.v1.WebhookClientConfig".into()
139    }
140
141    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
142        crate::schemars::json_schema!({
143            "description": "WebhookClientConfig contains the information to make a TLS connection with the webhook",
144            "type": "object",
145            "properties": {
146                "caBundle": {
147                    "description": "caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used.",
148                    "type": "string",
149                    "format": "byte",
150                },
151                "service": ({
152                    let mut schema_obj = __gen.subschema_for::<crate::api::admissionregistration::v1::ServiceReference>();
153                    schema_obj.ensure_object().insert("description".into(), "service is a reference to the service for this webhook. Either `service` or `url` must be specified.\n\nIf the webhook is running within the cluster, then you should use `service`.".into());
154                    schema_obj
155                }),
156                "url": {
157                    "description": "url gives the location of the webhook, in standard URL form (`scheme://host:port/path`). Exactly one of `url` or `service` must be specified.\n\nThe `host` should not refer to a service running in the cluster; use the `service` field instead. The host might be resolved via external DNS in some apiservers (e.g., `kube-apiserver` cannot resolve in-cluster DNS as that would be a layering violation). `host` may also be an IP address.\n\nPlease note that using `localhost` or `127.0.0.1` as a `host` is risky unless you take great care to run this webhook on all hosts which run an apiserver which might need to make calls to this webhook. Such installs are likely to be non-portable, i.e., not easy to turn up in a new cluster.\n\nThe scheme must be \"https\"; the URL must begin with \"https://\".\n\nA path is optional, and if present may be any string permissible in a URL. You may use the path to pass an arbitrary string to the webhook, for example, a cluster identifier.\n\nAttempting to use a user or basic auth e.g. \"user:password@\" is not allowed. Fragments (\"#...\") and query parameters (\"?...\") are not allowed, either.",
158                    "type": "string",
159                },
160            },
161        })
162    }
163}
164
165#[cfg(feature = "schemars08")]
166impl crate::schemars08::JsonSchema for WebhookClientConfig {
167    fn schema_name() -> std::string::String {
168        "io.k8s.api.admissionregistration.v1.WebhookClientConfig".into()
169    }
170
171    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
172        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
173            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
174                description: Some("WebhookClientConfig contains the information to make a TLS connection with the webhook".into()),
175                ..Default::default()
176            })),
177            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
178            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
179                properties: [
180                    (
181                        "caBundle".into(),
182                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
183                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
184                                description: Some("caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used.".into()),
185                                ..Default::default()
186                            })),
187                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
188                            format: Some("byte".into()),
189                            ..Default::default()
190                        }),
191                    ),
192                    (
193                        "service".into(),
194                        {
195                            let mut schema_obj = __gen.subschema_for::<crate::api::admissionregistration::v1::ServiceReference>().into_object();
196                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
197                                description: Some("service is a reference to the service for this webhook. Either `service` or `url` must be specified.\n\nIf the webhook is running within the cluster, then you should use `service`.".into()),
198                                ..Default::default()
199                            }));
200                            crate::schemars08::schema::Schema::Object(schema_obj)
201                        },
202                    ),
203                    (
204                        "url".into(),
205                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
206                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
207                                description: Some("url gives the location of the webhook, in standard URL form (`scheme://host:port/path`). Exactly one of `url` or `service` must be specified.\n\nThe `host` should not refer to a service running in the cluster; use the `service` field instead. The host might be resolved via external DNS in some apiservers (e.g., `kube-apiserver` cannot resolve in-cluster DNS as that would be a layering violation). `host` may also be an IP address.\n\nPlease note that using `localhost` or `127.0.0.1` as a `host` is risky unless you take great care to run this webhook on all hosts which run an apiserver which might need to make calls to this webhook. Such installs are likely to be non-portable, i.e., not easy to turn up in a new cluster.\n\nThe scheme must be \"https\"; the URL must begin with \"https://\".\n\nA path is optional, and if present may be any string permissible in a URL. You may use the path to pass an arbitrary string to the webhook, for example, a cluster identifier.\n\nAttempting to use a user or basic auth e.g. \"user:password@\" is not allowed. Fragments (\"#...\") and query parameters (\"?...\") are not allowed, either.".into()),
208                                ..Default::default()
209                            })),
210                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
211                            ..Default::default()
212                        }),
213                    ),
214                ].into(),
215                ..Default::default()
216            })),
217            ..Default::default()
218        })
219    }
220}