1// Generated from definition io.k8s.api.networking.v1.IngressSpec
23/// IngressSpec describes the Ingress the user wishes to exist.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct IngressSpec {
6/// defaultBackend is the backend that should handle requests that don't match any rule. If Rules are not specified, DefaultBackend must be specified. If DefaultBackend is not set, the handling of requests that do not match any of the rules will be up to the Ingress controller.
7pub default_backend: Option<crate::api::networking::v1::IngressBackend>,
89/// ingressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource, by a transitive connection (controller -\> IngressClass -\> Ingress resource). Although the `kubernetes.io/ingress.class` annotation (simple constant name) was never formally defined, it was widely supported by Ingress controllers to create a direct binding between Ingress controller and Ingress resources. Newly created Ingress resources should prefer using the field. However, even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present.
10pub ingress_class_name: Option<std::string::String>,
1112/// rules is a list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.
13pub rules: Option<std::vec::Vec<crate::api::networking::v1::IngressRule>>,
1415/// tls represents the TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.
16pub tls: Option<std::vec::Vec<crate::api::networking::v1::IngressTLS>>,
17}
1819impl crate::DeepMerge for IngressSpec {
20fn merge_from(&mut self, other: Self) {
21crate::DeepMerge::merge_from(&mut self.default_backend, other.default_backend);
22crate::DeepMerge::merge_from(&mut self.ingress_class_name, other.ingress_class_name);
23crate::merge_strategies::list::atomic(&mut self.rules, other.rules);
24crate::merge_strategies::list::atomic(&mut self.tls, other.tls);
25 }
26}
2728impl<'de> crate::serde::Deserialize<'de> for IngressSpec {
29fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30#[allow(non_camel_case_types)]
31enum Field {
32 Key_default_backend,
33 Key_ingress_class_name,
34 Key_rules,
35 Key_tls,
36 Other,
37 }
3839impl<'de> crate::serde::Deserialize<'de> for Field {
40fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41struct Visitor;
4243impl crate::serde::de::Visitor<'_> for Visitor {
44type Value = Field;
4546fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47 f.write_str("field identifier")
48 }
4950fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51Ok(match v {
52"defaultBackend" => Field::Key_default_backend,
53"ingressClassName" => Field::Key_ingress_class_name,
54"rules" => Field::Key_rules,
55"tls" => Field::Key_tls,
56_ => Field::Other,
57 })
58 }
59 }
6061 deserializer.deserialize_identifier(Visitor)
62 }
63 }
6465struct Visitor;
6667impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68type Value = IngressSpec;
6970fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("IngressSpec")
72 }
7374fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75let mut value_default_backend: Option<crate::api::networking::v1::IngressBackend> = None;
76let mut value_ingress_class_name: Option<std::string::String> = None;
77let mut value_rules: Option<std::vec::Vec<crate::api::networking::v1::IngressRule>> = None;
78let mut value_tls: Option<std::vec::Vec<crate::api::networking::v1::IngressTLS>> = None;
7980while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81match key {
82 Field::Key_default_backend => value_default_backend = crate::serde::de::MapAccess::next_value(&mut map)?,
83 Field::Key_ingress_class_name => value_ingress_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
84 Field::Key_rules => value_rules = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_tls => value_tls = crate::serde::de::MapAccess::next_value(&mut map)?,
86 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87 }
88 }
8990Ok(IngressSpec {
91 default_backend: value_default_backend,
92 ingress_class_name: value_ingress_class_name,
93 rules: value_rules,
94 tls: value_tls,
95 })
96 }
97 }
9899 deserializer.deserialize_struct(
100"IngressSpec",
101&[
102"defaultBackend",
103"ingressClassName",
104"rules",
105"tls",
106 ],
107 Visitor,
108 )
109 }
110}
111112impl crate::serde::Serialize for IngressSpec {
113fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114let mut state = serializer.serialize_struct(
115"IngressSpec",
116self.default_backend.as_ref().map_or(0, |_| 1) +
117self.ingress_class_name.as_ref().map_or(0, |_| 1) +
118self.rules.as_ref().map_or(0, |_| 1) +
119self.tls.as_ref().map_or(0, |_| 1),
120 )?;
121if let Some(value) = &self.default_backend {
122crate::serde::ser::SerializeStruct::serialize_field(&mut state, "defaultBackend", value)?;
123 }
124if let Some(value) = &self.ingress_class_name {
125crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ingressClassName", value)?;
126 }
127if let Some(value) = &self.rules {
128crate::serde::ser::SerializeStruct::serialize_field(&mut state, "rules", value)?;
129 }
130if let Some(value) = &self.tls {
131crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tls", value)?;
132 }
133crate::serde::ser::SerializeStruct::end(state)
134 }
135}
136137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for IngressSpec {
139fn schema_name() -> std::string::String {
140"io.k8s.api.networking.v1.IngressSpec".into()
141 }
142143fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
146 description: Some("IngressSpec describes the Ingress the user wishes to exist.".into()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
150 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
151 properties: [
152 (
153"defaultBackend".into(),
154 {
155let mut schema_obj = __gen.subschema_for::<crate::api::networking::v1::IngressBackend>().into_object();
156 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
157 description: Some("defaultBackend is the backend that should handle requests that don't match any rule. If Rules are not specified, DefaultBackend must be specified. If DefaultBackend is not set, the handling of requests that do not match any of the rules will be up to the Ingress controller.".into()),
158 ..Default::default()
159 }));
160crate::schemars::schema::Schema::Object(schema_obj)
161 },
162 ),
163 (
164"ingressClassName".into(),
165crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
166 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
167 description: Some("ingressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource, by a transitive connection (controller -> IngressClass -> Ingress resource). Although the `kubernetes.io/ingress.class` annotation (simple constant name) was never formally defined, it was widely supported by Ingress controllers to create a direct binding between Ingress controller and Ingress resources. Newly created Ingress resources should prefer using the field. However, even though the annotation is officially deprecated, for backwards compatibility reasons, ingress controllers should still honor that annotation if present.".into()),
168 ..Default::default()
169 })),
170 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
171 ..Default::default()
172 }),
173 ),
174 (
175"rules".into(),
176crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
177 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
178 description: Some("rules is a list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.".into()),
179 ..Default::default()
180 })),
181 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
182 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
183 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::networking::v1::IngressRule>()))),
184 ..Default::default()
185 })),
186 ..Default::default()
187 }),
188 ),
189 (
190"tls".into(),
191crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
192 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
193 description: Some("tls represents the TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.".into()),
194 ..Default::default()
195 })),
196 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
197 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
198 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::networking::v1::IngressTLS>()))),
199 ..Default::default()
200 })),
201 ..Default::default()
202 }),
203 ),
204 ].into(),
205 ..Default::default()
206 })),
207 ..Default::default()
208 })
209 }
210}