k8s_openapi/v1_35/api/core/v1/
pod_dns_config.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodDNSConfig {
6 pub nameservers: Option<std::vec::Vec<std::string::String>>,
8
9 pub options: Option<std::vec::Vec<crate::api::core::v1::PodDNSConfigOption>>,
11
12 pub searches: Option<std::vec::Vec<std::string::String>>,
14}
15
16impl crate::DeepMerge for PodDNSConfig {
17 fn merge_from(&mut self, other: Self) {
18 crate::merge_strategies::list::atomic(&mut self.nameservers, other.nameservers);
19 crate::merge_strategies::list::atomic(&mut self.options, other.options);
20 crate::merge_strategies::list::atomic(&mut self.searches, other.searches);
21 }
22}
23
24impl<'de> crate::serde::Deserialize<'de> for PodDNSConfig {
25 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26 #[allow(non_camel_case_types)]
27 enum Field {
28 Key_nameservers,
29 Key_options,
30 Key_searches,
31 Other,
32 }
33
34 impl<'de> crate::serde::Deserialize<'de> for Field {
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36 struct Visitor;
37
38 impl crate::serde::de::Visitor<'_> for Visitor {
39 type Value = Field;
40
41 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
42 f.write_str("field identifier")
43 }
44
45 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46 Ok(match v {
47 "nameservers" => Field::Key_nameservers,
48 "options" => Field::Key_options,
49 "searches" => Field::Key_searches,
50 _ => Field::Other,
51 })
52 }
53 }
54
55 deserializer.deserialize_identifier(Visitor)
56 }
57 }
58
59 struct Visitor;
60
61 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62 type Value = PodDNSConfig;
63
64 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("PodDNSConfig")
66 }
67
68 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69 let mut value_nameservers: Option<std::vec::Vec<std::string::String>> = None;
70 let mut value_options: Option<std::vec::Vec<crate::api::core::v1::PodDNSConfigOption>> = None;
71 let mut value_searches: Option<std::vec::Vec<std::string::String>> = None;
72
73 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74 match key {
75 Field::Key_nameservers => value_nameservers = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_options => value_options = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_searches => value_searches = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79 }
80 }
81
82 Ok(PodDNSConfig {
83 nameservers: value_nameservers,
84 options: value_options,
85 searches: value_searches,
86 })
87 }
88 }
89
90 deserializer.deserialize_struct(
91 "PodDNSConfig",
92 &[
93 "nameservers",
94 "options",
95 "searches",
96 ],
97 Visitor,
98 )
99 }
100}
101
102impl crate::serde::Serialize for PodDNSConfig {
103 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104 let mut state = serializer.serialize_struct(
105 "PodDNSConfig",
106 self.nameservers.as_ref().map_or(0, |_| 1) +
107 self.options.as_ref().map_or(0, |_| 1) +
108 self.searches.as_ref().map_or(0, |_| 1),
109 )?;
110 if let Some(value) = &self.nameservers {
111 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nameservers", value)?;
112 }
113 if let Some(value) = &self.options {
114 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "options", value)?;
115 }
116 if let Some(value) = &self.searches {
117 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "searches", value)?;
118 }
119 crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122
123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for PodDNSConfig {
125 fn schema_name() -> std::borrow::Cow<'static, str> {
126 "io.k8s.api.core.v1.PodDNSConfig".into()
127 }
128
129 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
130 crate::schemars::json_schema!({
131 "description": "PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.",
132 "type": "object",
133 "properties": {
134 "nameservers": {
135 "description": "A list of DNS name server IP addresses. This will be appended to the base nameservers generated from DNSPolicy. Duplicated nameservers will be removed.",
136 "type": "array",
137 "items": {
138 "type": "string",
139 },
140 },
141 "options": {
142 "description": "A list of DNS resolver options. This will be merged with the base options generated from DNSPolicy. Duplicated entries will be removed. Resolution options given in Options will override those that appear in the base DNSPolicy.",
143 "type": "array",
144 "items": (__gen.subschema_for::<crate::api::core::v1::PodDNSConfigOption>()),
145 },
146 "searches": {
147 "description": "A list of DNS search domains for host-name lookup. This will be appended to the base search paths generated from DNSPolicy. Duplicated search paths will be removed.",
148 "type": "array",
149 "items": {
150 "type": "string",
151 },
152 },
153 },
154 })
155 }
156}