k8s_openapi/v1_35/api/core/v1/
downward_api_volume_file.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DownwardAPIVolumeFile {
6 pub field_ref: Option<crate::api::core::v1::ObjectFieldSelector>,
8
9 pub mode: Option<i32>,
11
12 pub path: std::string::String,
14
15 pub resource_field_ref: Option<crate::api::core::v1::ResourceFieldSelector>,
17}
18
19impl crate::DeepMerge for DownwardAPIVolumeFile {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.field_ref, other.field_ref);
22 crate::DeepMerge::merge_from(&mut self.mode, other.mode);
23 crate::DeepMerge::merge_from(&mut self.path, other.path);
24 crate::DeepMerge::merge_from(&mut self.resource_field_ref, other.resource_field_ref);
25 }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for DownwardAPIVolumeFile {
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_field_ref,
33 Key_mode,
34 Key_path,
35 Key_resource_field_ref,
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 "fieldRef" => Field::Key_field_ref,
53 "mode" => Field::Key_mode,
54 "path" => Field::Key_path,
55 "resourceFieldRef" => Field::Key_resource_field_ref,
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 = DownwardAPIVolumeFile;
69
70 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("DownwardAPIVolumeFile")
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_field_ref: Option<crate::api::core::v1::ObjectFieldSelector> = None;
76 let mut value_mode: Option<i32> = None;
77 let mut value_path: Option<std::string::String> = None;
78 let mut value_resource_field_ref: Option<crate::api::core::v1::ResourceFieldSelector> = None;
79
80 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81 match key {
82 Field::Key_field_ref => value_field_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
83 Field::Key_mode => value_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
84 Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_resource_field_ref => value_resource_field_ref = 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(DownwardAPIVolumeFile {
91 field_ref: value_field_ref,
92 mode: value_mode,
93 path: value_path.unwrap_or_default(),
94 resource_field_ref: value_resource_field_ref,
95 })
96 }
97 }
98
99 deserializer.deserialize_struct(
100 "DownwardAPIVolumeFile",
101 &[
102 "fieldRef",
103 "mode",
104 "path",
105 "resourceFieldRef",
106 ],
107 Visitor,
108 )
109 }
110}
111
112impl crate::serde::Serialize for DownwardAPIVolumeFile {
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 "DownwardAPIVolumeFile",
116 1 +
117 self.field_ref.as_ref().map_or(0, |_| 1) +
118 self.mode.as_ref().map_or(0, |_| 1) +
119 self.resource_field_ref.as_ref().map_or(0, |_| 1),
120 )?;
121 if let Some(value) = &self.field_ref {
122 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fieldRef", value)?;
123 }
124 if let Some(value) = &self.mode {
125 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "mode", value)?;
126 }
127 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", &self.path)?;
128 if let Some(value) = &self.resource_field_ref {
129 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceFieldRef", value)?;
130 }
131 crate::serde::ser::SerializeStruct::end(state)
132 }
133}
134
135#[cfg(feature = "schemars")]
136impl crate::schemars::JsonSchema for DownwardAPIVolumeFile {
137 fn schema_name() -> std::borrow::Cow<'static, str> {
138 "io.k8s.api.core.v1.DownwardAPIVolumeFile".into()
139 }
140
141 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
142 crate::schemars::json_schema!({
143 "description": "DownwardAPIVolumeFile represents information to create the file containing the pod field",
144 "type": "object",
145 "properties": {
146 "fieldRef": ({
147 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectFieldSelector>();
148 schema_obj.ensure_object().insert("description".into(), "Required: Selects a field of the pod: only annotations, labels, name, namespace and uid are supported.".into());
149 schema_obj
150 }),
151 "mode": {
152 "description": "Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.",
153 "type": "integer",
154 "format": "int32",
155 },
156 "path": {
157 "description": "Required: Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'",
158 "type": "string",
159 },
160 "resourceFieldRef": ({
161 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ResourceFieldSelector>();
162 schema_obj.ensure_object().insert("description".into(), "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.".into());
163 schema_obj
164 }),
165 },
166 "required": [
167 "path",
168 ],
169 })
170 }
171}