k8s_openapi/v1_31/api/admissionregistration/v1/
webhook_client_config.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct WebhookClientConfig {
6 pub ca_bundle: Option<crate::ByteString>,
8
9 pub service: Option<crate::api::admissionregistration::v1::ServiceReference>,
13
14 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::string::String {
138 "io.k8s.api.admissionregistration.v1.WebhookClientConfig".into()
139 }
140
141 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
142 crate::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(),
152 crate::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 {
165 let 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 }));
170 crate::schemars::schema::Schema::Object(schema_obj)
171 },
172 ),
173 (
174 "url".into(),
175 crate::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}