k8s_openapi/v1_35/api/core/v1/
load_balancer_ingress.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct LoadBalancerIngress {
6 pub hostname: Option<std::string::String>,
8
9 pub ip: Option<std::string::String>,
11
12 pub ip_mode: Option<std::string::String>,
14
15 pub ports: Option<std::vec::Vec<crate::api::core::v1::PortStatus>>,
17}
18
19impl crate::DeepMerge for LoadBalancerIngress {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.hostname, other.hostname);
22 crate::DeepMerge::merge_from(&mut self.ip, other.ip);
23 crate::DeepMerge::merge_from(&mut self.ip_mode, other.ip_mode);
24 crate::merge_strategies::list::atomic(&mut self.ports, other.ports);
25 }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for LoadBalancerIngress {
29 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30 #[allow(non_camel_case_types)]
31 enum Field {
32 Key_hostname,
33 Key_ip,
34 Key_ip_mode,
35 Key_ports,
36 Other,
37 }
38
39 impl<'de> crate::serde::Deserialize<'de> for Field {
40 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41 struct Visitor;
42
43 impl crate::serde::de::Visitor<'_> for Visitor {
44 type Value = Field;
45
46 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47 f.write_str("field identifier")
48 }
49
50 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51 Ok(match v {
52 "hostname" => Field::Key_hostname,
53 "ip" => Field::Key_ip,
54 "ipMode" => Field::Key_ip_mode,
55 "ports" => Field::Key_ports,
56 _ => Field::Other,
57 })
58 }
59 }
60
61 deserializer.deserialize_identifier(Visitor)
62 }
63 }
64
65 struct Visitor;
66
67 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68 type Value = LoadBalancerIngress;
69
70 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("LoadBalancerIngress")
72 }
73
74 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75 let mut value_hostname: Option<std::string::String> = None;
76 let mut value_ip: Option<std::string::String> = None;
77 let mut value_ip_mode: Option<std::string::String> = None;
78 let mut value_ports: Option<std::vec::Vec<crate::api::core::v1::PortStatus>> = None;
79
80 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81 match key {
82 Field::Key_hostname => value_hostname = crate::serde::de::MapAccess::next_value(&mut map)?,
83 Field::Key_ip => value_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
84 Field::Key_ip_mode => value_ip_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_ports => value_ports = 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 }
89
90 Ok(LoadBalancerIngress {
91 hostname: value_hostname,
92 ip: value_ip,
93 ip_mode: value_ip_mode,
94 ports: value_ports,
95 })
96 }
97 }
98
99 deserializer.deserialize_struct(
100 "LoadBalancerIngress",
101 &[
102 "hostname",
103 "ip",
104 "ipMode",
105 "ports",
106 ],
107 Visitor,
108 )
109 }
110}
111
112impl crate::serde::Serialize for LoadBalancerIngress {
113 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114 let mut state = serializer.serialize_struct(
115 "LoadBalancerIngress",
116 self.hostname.as_ref().map_or(0, |_| 1) +
117 self.ip.as_ref().map_or(0, |_| 1) +
118 self.ip_mode.as_ref().map_or(0, |_| 1) +
119 self.ports.as_ref().map_or(0, |_| 1),
120 )?;
121 if let Some(value) = &self.hostname {
122 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostname", value)?;
123 }
124 if let Some(value) = &self.ip {
125 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ip", value)?;
126 }
127 if let Some(value) = &self.ip_mode {
128 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ipMode", value)?;
129 }
130 if let Some(value) = &self.ports {
131 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
132 }
133 crate::serde::ser::SerializeStruct::end(state)
134 }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for LoadBalancerIngress {
139 fn schema_name() -> std::borrow::Cow<'static, str> {
140 "io.k8s.api.core.v1.LoadBalancerIngress".into()
141 }
142
143 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144 crate::schemars::json_schema!({
145 "description": "LoadBalancerIngress represents the status of a load-balancer ingress point: traffic intended for the service should be sent to an ingress point.",
146 "type": "object",
147 "properties": {
148 "hostname": {
149 "description": "Hostname is set for load-balancer ingress points that are DNS based (typically AWS load-balancers)",
150 "type": "string",
151 },
152 "ip": {
153 "description": "IP is set for load-balancer ingress points that are IP based (typically GCE or OpenStack load-balancers)",
154 "type": "string",
155 },
156 "ipMode": {
157 "description": "IPMode specifies how the load-balancer IP behaves, and may only be specified when the ip field is specified. Setting this to \"VIP\" indicates that traffic is delivered to the node with the destination set to the load-balancer's IP and port. Setting this to \"Proxy\" indicates that traffic is delivered to the node or pod with the destination set to the node's IP and node port or the pod's IP and port. Service implementations may use this information to adjust traffic routing.",
158 "type": "string",
159 },
160 "ports": {
161 "description": "Ports is a list of records of service ports If used, every port defined in the service should have an entry in it",
162 "type": "array",
163 "items": (__gen.subschema_for::<crate::api::core::v1::PortStatus>()),
164 },
165 },
166 })
167 }
168}