1// Generated from definition io.k8s.api.admissionregistration.v1.WebhookClientConfig
23/// 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.
7pub ca_bundle: Option<crate::ByteString>,
89/// `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`.
12pub service: Option<crate::api::admissionregistration::v1::ServiceReference>,
1314/// `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.
25pub url: Option<std::string::String>,
26}
2728impl crate::DeepMerge for WebhookClientConfig {
29fn merge_from(&mut self, other: Self) {
30crate::DeepMerge::merge_from(&mut self.ca_bundle, other.ca_bundle);
31crate::DeepMerge::merge_from(&mut self.service, other.service);
32crate::DeepMerge::merge_from(&mut self.url, other.url);
33 }
34}
3536impl<'de> crate::serde::Deserialize<'de> for WebhookClientConfig {
37fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38#[allow(non_camel_case_types)]
39enum Field {
40 Key_ca_bundle,
41 Key_service,
42 Key_url,
43 Other,
44 }
4546impl<'de> crate::serde::Deserialize<'de> for Field {
47fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48struct Visitor;
4950impl crate::serde::de::Visitor<'_> for Visitor {
51type Value = Field;
5253fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
54 f.write_str("field identifier")
55 }
5657fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
58Ok(match v {
59"caBundle" => Field::Key_ca_bundle,
60"service" => Field::Key_service,
61"url" => Field::Key_url,
62_ => Field::Other,
63 })
64 }
65 }
6667 deserializer.deserialize_identifier(Visitor)
68 }
69 }
7071struct Visitor;
7273impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74type Value = WebhookClientConfig;
7576fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77 f.write_str("WebhookClientConfig")
78 }
7980fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81let mut value_ca_bundle: Option<crate::ByteString> = None;
82let mut value_service: Option<crate::api::admissionregistration::v1::ServiceReference> = None;
83let mut value_url: Option<std::string::String> = None;
8485while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
86match 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 }
9394Ok(WebhookClientConfig {
95 ca_bundle: value_ca_bundle,
96 service: value_service,
97 url: value_url,
98 })
99 }
100 }
101102 deserializer.deserialize_struct(
103"WebhookClientConfig",
104&[
105"caBundle",
106"service",
107"url",
108 ],
109 Visitor,
110 )
111 }
112}
113114impl crate::serde::Serialize for WebhookClientConfig {
115fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116let mut state = serializer.serialize_struct(
117"WebhookClientConfig",
118self.ca_bundle.as_ref().map_or(0, |_| 1) +
119self.service.as_ref().map_or(0, |_| 1) +
120self.url.as_ref().map_or(0, |_| 1),
121 )?;
122if let Some(value) = &self.ca_bundle {
123crate::serde::ser::SerializeStruct::serialize_field(&mut state, "caBundle", value)?;
124 }
125if let Some(value) = &self.service {
126crate::serde::ser::SerializeStruct::serialize_field(&mut state, "service", value)?;
127 }
128if let Some(value) = &self.url {
129crate::serde::ser::SerializeStruct::serialize_field(&mut state, "url", value)?;
130 }
131crate::serde::ser::SerializeStruct::end(state)
132 }
133}
134135#[cfg(feature = "schemars")]
136impl crate::schemars::JsonSchema for WebhookClientConfig {
137fn schema_name() -> std::string::String {
138"io.k8s.api.admissionregistration.v1.WebhookClientConfig".into()
139 }
140141fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
142crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
143 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
144 description: Some("WebhookClientConfig contains the information to make a TLS connection with the webhook".into()),
145 ..Default::default()
146 })),
147 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
148 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
149 properties: [
150 (
151"caBundle".into(),
152crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
153 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
154 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()),
155 ..Default::default()
156 })),
157 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
158 format: Some("byte".into()),
159 ..Default::default()
160 }),
161 ),
162 (
163"service".into(),
164 {
165let mut schema_obj = __gen.subschema_for::<crate::api::admissionregistration::v1::ServiceReference>().into_object();
166 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
167 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()),
168 ..Default::default()
169 }));
170crate::schemars::schema::Schema::Object(schema_obj)
171 },
172 ),
173 (
174"url".into(),
175crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
176 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
177 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()),
178 ..Default::default()
179 })),
180 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
181 ..Default::default()
182 }),
183 ),
184 ].into(),
185 ..Default::default()
186 })),
187 ..Default::default()
188 })
189 }
190}