k8s_openapi/v1_30/api/core/v1/
gce_persistent_disk_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
7pub struct GCEPersistentDiskVolumeSource {
8 pub fs_type: Option<String>,
10
11 pub partition: Option<i32>,
13
14 pub pd_name: String,
16
17 pub read_only: Option<bool>,
19}
20
21impl crate::DeepMerge for GCEPersistentDiskVolumeSource {
22 fn merge_from(&mut self, other: Self) {
23 crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
24 crate::DeepMerge::merge_from(&mut self.partition, other.partition);
25 crate::DeepMerge::merge_from(&mut self.pd_name, other.pd_name);
26 crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
27 }
28}
29
30impl<'de> crate::serde::Deserialize<'de> for GCEPersistentDiskVolumeSource {
31 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32 #[allow(non_camel_case_types)]
33 enum Field {
34 Key_fs_type,
35 Key_partition,
36 Key_pd_name,
37 Key_read_only,
38 Other,
39 }
40
41 impl<'de> crate::serde::Deserialize<'de> for Field {
42 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
43 struct Visitor;
44
45 impl crate::serde::de::Visitor<'_> for Visitor {
46 type Value = Field;
47
48 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 f.write_str("field identifier")
50 }
51
52 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
53 Ok(match v {
54 "fsType" => Field::Key_fs_type,
55 "partition" => Field::Key_partition,
56 "pdName" => Field::Key_pd_name,
57 "readOnly" => Field::Key_read_only,
58 _ => Field::Other,
59 })
60 }
61 }
62
63 deserializer.deserialize_identifier(Visitor)
64 }
65 }
66
67 struct Visitor;
68
69 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
70 type Value = GCEPersistentDiskVolumeSource;
71
72 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
73 f.write_str("GCEPersistentDiskVolumeSource")
74 }
75
76 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
77 let mut value_fs_type: Option<String> = None;
78 let mut value_partition: Option<i32> = None;
79 let mut value_pd_name: Option<String> = None;
80 let mut value_read_only: Option<bool> = None;
81
82 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83 match key {
84 Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_partition => value_partition = crate::serde::de::MapAccess::next_value(&mut map)?,
86 Field::Key_pd_name => value_pd_name = crate::serde::de::MapAccess::next_value(&mut map)?,
87 Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
88 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
89 }
90 }
91
92 Ok(GCEPersistentDiskVolumeSource {
93 fs_type: value_fs_type,
94 partition: value_partition,
95 pd_name: value_pd_name.unwrap_or_default(),
96 read_only: value_read_only,
97 })
98 }
99 }
100
101 deserializer.deserialize_struct(
102 "GCEPersistentDiskVolumeSource",
103 &[
104 "fsType",
105 "partition",
106 "pdName",
107 "readOnly",
108 ],
109 Visitor,
110 )
111 }
112}
113
114impl crate::serde::Serialize for GCEPersistentDiskVolumeSource {
115 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116 let mut state = serializer.serialize_struct(
117 "GCEPersistentDiskVolumeSource",
118 1 +
119 self.fs_type.as_ref().map_or(0, |_| 1) +
120 self.partition.as_ref().map_or(0, |_| 1) +
121 self.read_only.as_ref().map_or(0, |_| 1),
122 )?;
123 if let Some(value) = &self.fs_type {
124 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
125 }
126 if let Some(value) = &self.partition {
127 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "partition", value)?;
128 }
129 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pdName", &self.pd_name)?;
130 if let Some(value) = &self.read_only {
131 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
132 }
133 crate::serde::ser::SerializeStruct::end(state)
134 }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for GCEPersistentDiskVolumeSource {
139 fn schema_name() -> String {
140 "io.k8s.api.core.v1.GCEPersistentDiskVolumeSource".to_owned()
141 }
142
143 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(Box::new(crate::schemars::schema::Metadata {
146 description: Some("Represents a Persistent Disk resource in Google Compute Engine.\n\nA GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.".to_owned()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
150 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
151 properties: [
152 (
153 "fsType".to_owned(),
154 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
155 metadata: Some(Box::new(crate::schemars::schema::Metadata {
156 description: Some("fsType is filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk".to_owned()),
157 ..Default::default()
158 })),
159 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
160 ..Default::default()
161 }),
162 ),
163 (
164 "partition".to_owned(),
165 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
166 metadata: Some(Box::new(crate::schemars::schema::Metadata {
167 description: Some("partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk".to_owned()),
168 ..Default::default()
169 })),
170 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
171 format: Some("int32".to_owned()),
172 ..Default::default()
173 }),
174 ),
175 (
176 "pdName".to_owned(),
177 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
178 metadata: Some(Box::new(crate::schemars::schema::Metadata {
179 description: Some("pdName is unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk".to_owned()),
180 ..Default::default()
181 })),
182 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
183 ..Default::default()
184 }),
185 ),
186 (
187 "readOnly".to_owned(),
188 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
189 metadata: Some(Box::new(crate::schemars::schema::Metadata {
190 description: Some("readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk".to_owned()),
191 ..Default::default()
192 })),
193 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
194 ..Default::default()
195 }),
196 ),
197 ].into(),
198 required: [
199 "pdName".to_owned(),
200 ].into(),
201 ..Default::default()
202 })),
203 ..Default::default()
204 })
205 }
206}