1// Generated from definition io.k8s.api.networking.v1.IngressRule
23/// IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct IngressRule {
6/// host is the fully qualified domain name of a network host, as defined by RFC 3986. Note the following deviations from the "host" part of the URI as defined in RFC 3986: 1. IPs are not allowed. Currently an IngressRuleValue can only apply to
7 /// the IP in the Spec of the parent Ingress.
8 /// 2. The `:` delimiter is not respected because ports are not allowed.
9 /// Currently the port of an Ingress is implicitly :80 for http and
10 /// :443 for https.
11 /// Both these may change in the future. Incoming requests are matched against the host before the IngressRuleValue. If the host is unspecified, the Ingress routes all traffic based on the specified IngressRuleValue.
12 ///
13 /// host can be "precise" which is a domain name without the terminating dot of a network host (e.g. "foo.bar.com") or "wildcard", which is a domain name prefixed with a single wildcard label (e.g. "*.foo.com"). The wildcard character '*' must appear by itself as the first DNS label and matches only a single label. You cannot have a wildcard label by itself (e.g. Host == "*"). Requests will be matched against the Host field in the following way: 1. If host is precise, the request matches this rule if the http host header is equal to Host. 2. If host is a wildcard, then the request matches this rule if the http host header is to equal to the suffix (removing the first label) of the wildcard rule.
14pub host: Option<std::string::String>,
1516pub http: Option<crate::api::networking::v1::HTTPIngressRuleValue>,
17}
1819impl crate::DeepMerge for IngressRule {
20fn merge_from(&mut self, other: Self) {
21crate::DeepMerge::merge_from(&mut self.host, other.host);
22crate::DeepMerge::merge_from(&mut self.http, other.http);
23 }
24}
2526impl<'de> crate::serde::Deserialize<'de> for IngressRule {
27fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28#[allow(non_camel_case_types)]
29enum Field {
30 Key_host,
31 Key_http,
32 Other,
33 }
3435impl<'de> crate::serde::Deserialize<'de> for Field {
36fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
37struct Visitor;
3839impl crate::serde::de::Visitor<'_> for Visitor {
40type Value = Field;
4142fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
43 f.write_str("field identifier")
44 }
4546fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
47Ok(match v {
48"host" => Field::Key_host,
49"http" => Field::Key_http,
50_ => Field::Other,
51 })
52 }
53 }
5455 deserializer.deserialize_identifier(Visitor)
56 }
57 }
5859struct Visitor;
6061impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62type Value = IngressRule;
6364fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("IngressRule")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_host: Option<std::string::String> = None;
70let mut value_http: Option<crate::api::networking::v1::HTTPIngressRuleValue> = None;
7172while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
73match key {
74 Field::Key_host => value_host = crate::serde::de::MapAccess::next_value(&mut map)?,
75 Field::Key_http => value_http = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
77 }
78 }
7980Ok(IngressRule {
81 host: value_host,
82 http: value_http,
83 })
84 }
85 }
8687 deserializer.deserialize_struct(
88"IngressRule",
89&[
90"host",
91"http",
92 ],
93 Visitor,
94 )
95 }
96}
9798impl crate::serde::Serialize for IngressRule {
99fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
100let mut state = serializer.serialize_struct(
101"IngressRule",
102self.host.as_ref().map_or(0, |_| 1) +
103self.http.as_ref().map_or(0, |_| 1),
104 )?;
105if let Some(value) = &self.host {
106crate::serde::ser::SerializeStruct::serialize_field(&mut state, "host", value)?;
107 }
108if let Some(value) = &self.http {
109crate::serde::ser::SerializeStruct::serialize_field(&mut state, "http", value)?;
110 }
111crate::serde::ser::SerializeStruct::end(state)
112 }
113}
114115#[cfg(feature = "schemars")]
116impl crate::schemars::JsonSchema for IngressRule {
117fn schema_name() -> std::string::String {
118"io.k8s.api.networking.v1.IngressRule".into()
119 }
120121fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
122crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
123 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
124 description: Some("IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.".into()),
125 ..Default::default()
126 })),
127 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
128 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
129 properties: [
130 (
131"host".into(),
132crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
133 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
134 description: Some("host is the fully qualified domain name of a network host, as defined by RFC 3986. Note the following deviations from the \"host\" part of the URI as defined in RFC 3986: 1. IPs are not allowed. Currently an IngressRuleValue can only apply to\n the IP in the Spec of the parent Ingress.\n2. The `:` delimiter is not respected because ports are not allowed.\n\t Currently the port of an Ingress is implicitly :80 for http and\n\t :443 for https.\nBoth these may change in the future. Incoming requests are matched against the host before the IngressRuleValue. If the host is unspecified, the Ingress routes all traffic based on the specified IngressRuleValue.\n\nhost can be \"precise\" which is a domain name without the terminating dot of a network host (e.g. \"foo.bar.com\") or \"wildcard\", which is a domain name prefixed with a single wildcard label (e.g. \"*.foo.com\"). The wildcard character '*' must appear by itself as the first DNS label and matches only a single label. You cannot have a wildcard label by itself (e.g. Host == \"*\"). Requests will be matched against the Host field in the following way: 1. If host is precise, the request matches this rule if the http host header is equal to Host. 2. If host is a wildcard, then the request matches this rule if the http host header is to equal to the suffix (removing the first label) of the wildcard rule.".into()),
135 ..Default::default()
136 })),
137 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
138 ..Default::default()
139 }),
140 ),
141 (
142"http".into(),
143 __gen.subschema_for::<crate::api::networking::v1::HTTPIngressRuleValue>(),
144 ),
145 ].into(),
146 ..Default::default()
147 })),
148 ..Default::default()
149 })
150 }
151}