k8s_openapi/v1_30/api/core/v1/
volume.rs

1// Generated from definition io.k8s.api.core.v1.Volume
2
3/// Volume represents a named volume in a pod that may be accessed by any container in the pod.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Volume {
6    /// awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore
7    pub aws_elastic_block_store: Option<crate::api::core::v1::AWSElasticBlockStoreVolumeSource>,
8
9    /// azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.
10    pub azure_disk: Option<crate::api::core::v1::AzureDiskVolumeSource>,
11
12    /// azureFile represents an Azure File Service mount on the host and bind mount to the pod.
13    pub azure_file: Option<crate::api::core::v1::AzureFileVolumeSource>,
14
15    /// cephFS represents a Ceph FS mount on the host that shares a pod's lifetime
16    pub cephfs: Option<crate::api::core::v1::CephFSVolumeSource>,
17
18    /// cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md
19    pub cinder: Option<crate::api::core::v1::CinderVolumeSource>,
20
21    /// configMap represents a configMap that should populate this volume
22    pub config_map: Option<crate::api::core::v1::ConfigMapVolumeSource>,
23
24    /// csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).
25    pub csi: Option<crate::api::core::v1::CSIVolumeSource>,
26
27    /// downwardAPI represents downward API about the pod that should populate this volume
28    pub downward_api: Option<crate::api::core::v1::DownwardAPIVolumeSource>,
29
30    /// emptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir
31    pub empty_dir: Option<crate::api::core::v1::EmptyDirVolumeSource>,
32
33    /// ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed.
34    ///
35    /// Use this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity
36    ///    tracking are needed,
37    /// c) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through
38    ///    a PersistentVolumeClaim (see EphemeralVolumeSource for more
39    ///    information on the connection between this volume type
40    ///    and PersistentVolumeClaim).
41    ///
42    /// Use PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod.
43    ///
44    /// Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information.
45    ///
46    /// A pod can use both types of ephemeral volumes and persistent volumes at the same time.
47    pub ephemeral: Option<crate::api::core::v1::EphemeralVolumeSource>,
48
49    /// fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.
50    pub fc: Option<crate::api::core::v1::FCVolumeSource>,
51
52    /// flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.
53    pub flex_volume: Option<crate::api::core::v1::FlexVolumeSource>,
54
55    /// flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running
56    pub flocker: Option<crate::api::core::v1::FlockerVolumeSource>,
57
58    /// gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
59    pub gce_persistent_disk: Option<crate::api::core::v1::GCEPersistentDiskVolumeSource>,
60
61    /// gitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.
62    pub git_repo: Option<crate::api::core::v1::GitRepoVolumeSource>,
63
64    /// glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md
65    pub glusterfs: Option<crate::api::core::v1::GlusterfsVolumeSource>,
66
67    /// hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath
68    pub host_path: Option<crate::api::core::v1::HostPathVolumeSource>,
69
70    /// iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md
71    pub iscsi: Option<crate::api::core::v1::ISCSIVolumeSource>,
72
73    /// name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
74    pub name: std::string::String,
75
76    /// nfs represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
77    pub nfs: Option<crate::api::core::v1::NFSVolumeSource>,
78
79    /// persistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
80    pub persistent_volume_claim: Option<crate::api::core::v1::PersistentVolumeClaimVolumeSource>,
81
82    /// photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
83    pub photon_persistent_disk: Option<crate::api::core::v1::PhotonPersistentDiskVolumeSource>,
84
85    /// portworxVolume represents a portworx volume attached and mounted on kubelets host machine
86    pub portworx_volume: Option<crate::api::core::v1::PortworxVolumeSource>,
87
88    /// projected items for all in one resources secrets, configmaps, and downward API
89    pub projected: Option<crate::api::core::v1::ProjectedVolumeSource>,
90
91    /// quobyte represents a Quobyte mount on the host that shares a pod's lifetime
92    pub quobyte: Option<crate::api::core::v1::QuobyteVolumeSource>,
93
94    /// rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md
95    pub rbd: Option<crate::api::core::v1::RBDVolumeSource>,
96
97    /// scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.
98    pub scale_io: Option<crate::api::core::v1::ScaleIOVolumeSource>,
99
100    /// secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
101    pub secret: Option<crate::api::core::v1::SecretVolumeSource>,
102
103    /// storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.
104    pub storageos: Option<crate::api::core::v1::StorageOSVolumeSource>,
105
106    /// vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine
107    pub vsphere_volume: Option<crate::api::core::v1::VsphereVirtualDiskVolumeSource>,
108}
109
110impl crate::DeepMerge for Volume {
111    fn merge_from(&mut self, other: Self) {
112        crate::DeepMerge::merge_from(&mut self.aws_elastic_block_store, other.aws_elastic_block_store);
113        crate::DeepMerge::merge_from(&mut self.azure_disk, other.azure_disk);
114        crate::DeepMerge::merge_from(&mut self.azure_file, other.azure_file);
115        crate::DeepMerge::merge_from(&mut self.cephfs, other.cephfs);
116        crate::DeepMerge::merge_from(&mut self.cinder, other.cinder);
117        crate::DeepMerge::merge_from(&mut self.config_map, other.config_map);
118        crate::DeepMerge::merge_from(&mut self.csi, other.csi);
119        crate::DeepMerge::merge_from(&mut self.downward_api, other.downward_api);
120        crate::DeepMerge::merge_from(&mut self.empty_dir, other.empty_dir);
121        crate::DeepMerge::merge_from(&mut self.ephemeral, other.ephemeral);
122        crate::DeepMerge::merge_from(&mut self.fc, other.fc);
123        crate::DeepMerge::merge_from(&mut self.flex_volume, other.flex_volume);
124        crate::DeepMerge::merge_from(&mut self.flocker, other.flocker);
125        crate::DeepMerge::merge_from(&mut self.gce_persistent_disk, other.gce_persistent_disk);
126        crate::DeepMerge::merge_from(&mut self.git_repo, other.git_repo);
127        crate::DeepMerge::merge_from(&mut self.glusterfs, other.glusterfs);
128        crate::DeepMerge::merge_from(&mut self.host_path, other.host_path);
129        crate::DeepMerge::merge_from(&mut self.iscsi, other.iscsi);
130        crate::DeepMerge::merge_from(&mut self.name, other.name);
131        crate::DeepMerge::merge_from(&mut self.nfs, other.nfs);
132        crate::DeepMerge::merge_from(&mut self.persistent_volume_claim, other.persistent_volume_claim);
133        crate::DeepMerge::merge_from(&mut self.photon_persistent_disk, other.photon_persistent_disk);
134        crate::DeepMerge::merge_from(&mut self.portworx_volume, other.portworx_volume);
135        crate::DeepMerge::merge_from(&mut self.projected, other.projected);
136        crate::DeepMerge::merge_from(&mut self.quobyte, other.quobyte);
137        crate::DeepMerge::merge_from(&mut self.rbd, other.rbd);
138        crate::DeepMerge::merge_from(&mut self.scale_io, other.scale_io);
139        crate::DeepMerge::merge_from(&mut self.secret, other.secret);
140        crate::DeepMerge::merge_from(&mut self.storageos, other.storageos);
141        crate::DeepMerge::merge_from(&mut self.vsphere_volume, other.vsphere_volume);
142    }
143}
144
145impl<'de> crate::serde::Deserialize<'de> for Volume {
146    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
147        #[allow(non_camel_case_types)]
148        enum Field {
149            Key_aws_elastic_block_store,
150            Key_azure_disk,
151            Key_azure_file,
152            Key_cephfs,
153            Key_cinder,
154            Key_config_map,
155            Key_csi,
156            Key_downward_api,
157            Key_empty_dir,
158            Key_ephemeral,
159            Key_fc,
160            Key_flex_volume,
161            Key_flocker,
162            Key_gce_persistent_disk,
163            Key_git_repo,
164            Key_glusterfs,
165            Key_host_path,
166            Key_iscsi,
167            Key_name,
168            Key_nfs,
169            Key_persistent_volume_claim,
170            Key_photon_persistent_disk,
171            Key_portworx_volume,
172            Key_projected,
173            Key_quobyte,
174            Key_rbd,
175            Key_scale_io,
176            Key_secret,
177            Key_storageos,
178            Key_vsphere_volume,
179            Other,
180        }
181
182        impl<'de> crate::serde::Deserialize<'de> for Field {
183            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
184                struct Visitor;
185
186                impl crate::serde::de::Visitor<'_> for Visitor {
187                    type Value = Field;
188
189                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
190                        f.write_str("field identifier")
191                    }
192
193                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
194                        Ok(match v {
195                            "awsElasticBlockStore" => Field::Key_aws_elastic_block_store,
196                            "azureDisk" => Field::Key_azure_disk,
197                            "azureFile" => Field::Key_azure_file,
198                            "cephfs" => Field::Key_cephfs,
199                            "cinder" => Field::Key_cinder,
200                            "configMap" => Field::Key_config_map,
201                            "csi" => Field::Key_csi,
202                            "downwardAPI" => Field::Key_downward_api,
203                            "emptyDir" => Field::Key_empty_dir,
204                            "ephemeral" => Field::Key_ephemeral,
205                            "fc" => Field::Key_fc,
206                            "flexVolume" => Field::Key_flex_volume,
207                            "flocker" => Field::Key_flocker,
208                            "gcePersistentDisk" => Field::Key_gce_persistent_disk,
209                            "gitRepo" => Field::Key_git_repo,
210                            "glusterfs" => Field::Key_glusterfs,
211                            "hostPath" => Field::Key_host_path,
212                            "iscsi" => Field::Key_iscsi,
213                            "name" => Field::Key_name,
214                            "nfs" => Field::Key_nfs,
215                            "persistentVolumeClaim" => Field::Key_persistent_volume_claim,
216                            "photonPersistentDisk" => Field::Key_photon_persistent_disk,
217                            "portworxVolume" => Field::Key_portworx_volume,
218                            "projected" => Field::Key_projected,
219                            "quobyte" => Field::Key_quobyte,
220                            "rbd" => Field::Key_rbd,
221                            "scaleIO" => Field::Key_scale_io,
222                            "secret" => Field::Key_secret,
223                            "storageos" => Field::Key_storageos,
224                            "vsphereVolume" => Field::Key_vsphere_volume,
225                            _ => Field::Other,
226                        })
227                    }
228                }
229
230                deserializer.deserialize_identifier(Visitor)
231            }
232        }
233
234        struct Visitor;
235
236        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
237            type Value = Volume;
238
239            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
240                f.write_str("Volume")
241            }
242
243            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
244                let mut value_aws_elastic_block_store: Option<crate::api::core::v1::AWSElasticBlockStoreVolumeSource> = None;
245                let mut value_azure_disk: Option<crate::api::core::v1::AzureDiskVolumeSource> = None;
246                let mut value_azure_file: Option<crate::api::core::v1::AzureFileVolumeSource> = None;
247                let mut value_cephfs: Option<crate::api::core::v1::CephFSVolumeSource> = None;
248                let mut value_cinder: Option<crate::api::core::v1::CinderVolumeSource> = None;
249                let mut value_config_map: Option<crate::api::core::v1::ConfigMapVolumeSource> = None;
250                let mut value_csi: Option<crate::api::core::v1::CSIVolumeSource> = None;
251                let mut value_downward_api: Option<crate::api::core::v1::DownwardAPIVolumeSource> = None;
252                let mut value_empty_dir: Option<crate::api::core::v1::EmptyDirVolumeSource> = None;
253                let mut value_ephemeral: Option<crate::api::core::v1::EphemeralVolumeSource> = None;
254                let mut value_fc: Option<crate::api::core::v1::FCVolumeSource> = None;
255                let mut value_flex_volume: Option<crate::api::core::v1::FlexVolumeSource> = None;
256                let mut value_flocker: Option<crate::api::core::v1::FlockerVolumeSource> = None;
257                let mut value_gce_persistent_disk: Option<crate::api::core::v1::GCEPersistentDiskVolumeSource> = None;
258                let mut value_git_repo: Option<crate::api::core::v1::GitRepoVolumeSource> = None;
259                let mut value_glusterfs: Option<crate::api::core::v1::GlusterfsVolumeSource> = None;
260                let mut value_host_path: Option<crate::api::core::v1::HostPathVolumeSource> = None;
261                let mut value_iscsi: Option<crate::api::core::v1::ISCSIVolumeSource> = None;
262                let mut value_name: Option<std::string::String> = None;
263                let mut value_nfs: Option<crate::api::core::v1::NFSVolumeSource> = None;
264                let mut value_persistent_volume_claim: Option<crate::api::core::v1::PersistentVolumeClaimVolumeSource> = None;
265                let mut value_photon_persistent_disk: Option<crate::api::core::v1::PhotonPersistentDiskVolumeSource> = None;
266                let mut value_portworx_volume: Option<crate::api::core::v1::PortworxVolumeSource> = None;
267                let mut value_projected: Option<crate::api::core::v1::ProjectedVolumeSource> = None;
268                let mut value_quobyte: Option<crate::api::core::v1::QuobyteVolumeSource> = None;
269                let mut value_rbd: Option<crate::api::core::v1::RBDVolumeSource> = None;
270                let mut value_scale_io: Option<crate::api::core::v1::ScaleIOVolumeSource> = None;
271                let mut value_secret: Option<crate::api::core::v1::SecretVolumeSource> = None;
272                let mut value_storageos: Option<crate::api::core::v1::StorageOSVolumeSource> = None;
273                let mut value_vsphere_volume: Option<crate::api::core::v1::VsphereVirtualDiskVolumeSource> = None;
274
275                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
276                    match key {
277                        Field::Key_aws_elastic_block_store => value_aws_elastic_block_store = crate::serde::de::MapAccess::next_value(&mut map)?,
278                        Field::Key_azure_disk => value_azure_disk = crate::serde::de::MapAccess::next_value(&mut map)?,
279                        Field::Key_azure_file => value_azure_file = crate::serde::de::MapAccess::next_value(&mut map)?,
280                        Field::Key_cephfs => value_cephfs = crate::serde::de::MapAccess::next_value(&mut map)?,
281                        Field::Key_cinder => value_cinder = crate::serde::de::MapAccess::next_value(&mut map)?,
282                        Field::Key_config_map => value_config_map = crate::serde::de::MapAccess::next_value(&mut map)?,
283                        Field::Key_csi => value_csi = crate::serde::de::MapAccess::next_value(&mut map)?,
284                        Field::Key_downward_api => value_downward_api = crate::serde::de::MapAccess::next_value(&mut map)?,
285                        Field::Key_empty_dir => value_empty_dir = crate::serde::de::MapAccess::next_value(&mut map)?,
286                        Field::Key_ephemeral => value_ephemeral = crate::serde::de::MapAccess::next_value(&mut map)?,
287                        Field::Key_fc => value_fc = crate::serde::de::MapAccess::next_value(&mut map)?,
288                        Field::Key_flex_volume => value_flex_volume = crate::serde::de::MapAccess::next_value(&mut map)?,
289                        Field::Key_flocker => value_flocker = crate::serde::de::MapAccess::next_value(&mut map)?,
290                        Field::Key_gce_persistent_disk => value_gce_persistent_disk = crate::serde::de::MapAccess::next_value(&mut map)?,
291                        Field::Key_git_repo => value_git_repo = crate::serde::de::MapAccess::next_value(&mut map)?,
292                        Field::Key_glusterfs => value_glusterfs = crate::serde::de::MapAccess::next_value(&mut map)?,
293                        Field::Key_host_path => value_host_path = crate::serde::de::MapAccess::next_value(&mut map)?,
294                        Field::Key_iscsi => value_iscsi = crate::serde::de::MapAccess::next_value(&mut map)?,
295                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
296                        Field::Key_nfs => value_nfs = crate::serde::de::MapAccess::next_value(&mut map)?,
297                        Field::Key_persistent_volume_claim => value_persistent_volume_claim = crate::serde::de::MapAccess::next_value(&mut map)?,
298                        Field::Key_photon_persistent_disk => value_photon_persistent_disk = crate::serde::de::MapAccess::next_value(&mut map)?,
299                        Field::Key_portworx_volume => value_portworx_volume = crate::serde::de::MapAccess::next_value(&mut map)?,
300                        Field::Key_projected => value_projected = crate::serde::de::MapAccess::next_value(&mut map)?,
301                        Field::Key_quobyte => value_quobyte = crate::serde::de::MapAccess::next_value(&mut map)?,
302                        Field::Key_rbd => value_rbd = crate::serde::de::MapAccess::next_value(&mut map)?,
303                        Field::Key_scale_io => value_scale_io = crate::serde::de::MapAccess::next_value(&mut map)?,
304                        Field::Key_secret => value_secret = crate::serde::de::MapAccess::next_value(&mut map)?,
305                        Field::Key_storageos => value_storageos = crate::serde::de::MapAccess::next_value(&mut map)?,
306                        Field::Key_vsphere_volume => value_vsphere_volume = crate::serde::de::MapAccess::next_value(&mut map)?,
307                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
308                    }
309                }
310
311                Ok(Volume {
312                    aws_elastic_block_store: value_aws_elastic_block_store,
313                    azure_disk: value_azure_disk,
314                    azure_file: value_azure_file,
315                    cephfs: value_cephfs,
316                    cinder: value_cinder,
317                    config_map: value_config_map,
318                    csi: value_csi,
319                    downward_api: value_downward_api,
320                    empty_dir: value_empty_dir,
321                    ephemeral: value_ephemeral,
322                    fc: value_fc,
323                    flex_volume: value_flex_volume,
324                    flocker: value_flocker,
325                    gce_persistent_disk: value_gce_persistent_disk,
326                    git_repo: value_git_repo,
327                    glusterfs: value_glusterfs,
328                    host_path: value_host_path,
329                    iscsi: value_iscsi,
330                    name: value_name.unwrap_or_default(),
331                    nfs: value_nfs,
332                    persistent_volume_claim: value_persistent_volume_claim,
333                    photon_persistent_disk: value_photon_persistent_disk,
334                    portworx_volume: value_portworx_volume,
335                    projected: value_projected,
336                    quobyte: value_quobyte,
337                    rbd: value_rbd,
338                    scale_io: value_scale_io,
339                    secret: value_secret,
340                    storageos: value_storageos,
341                    vsphere_volume: value_vsphere_volume,
342                })
343            }
344        }
345
346        deserializer.deserialize_struct(
347            "Volume",
348            &[
349                "awsElasticBlockStore",
350                "azureDisk",
351                "azureFile",
352                "cephfs",
353                "cinder",
354                "configMap",
355                "csi",
356                "downwardAPI",
357                "emptyDir",
358                "ephemeral",
359                "fc",
360                "flexVolume",
361                "flocker",
362                "gcePersistentDisk",
363                "gitRepo",
364                "glusterfs",
365                "hostPath",
366                "iscsi",
367                "name",
368                "nfs",
369                "persistentVolumeClaim",
370                "photonPersistentDisk",
371                "portworxVolume",
372                "projected",
373                "quobyte",
374                "rbd",
375                "scaleIO",
376                "secret",
377                "storageos",
378                "vsphereVolume",
379            ],
380            Visitor,
381        )
382    }
383}
384
385impl crate::serde::Serialize for Volume {
386    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
387        let mut state = serializer.serialize_struct(
388            "Volume",
389            1 +
390            self.aws_elastic_block_store.as_ref().map_or(0, |_| 1) +
391            self.azure_disk.as_ref().map_or(0, |_| 1) +
392            self.azure_file.as_ref().map_or(0, |_| 1) +
393            self.cephfs.as_ref().map_or(0, |_| 1) +
394            self.cinder.as_ref().map_or(0, |_| 1) +
395            self.config_map.as_ref().map_or(0, |_| 1) +
396            self.csi.as_ref().map_or(0, |_| 1) +
397            self.downward_api.as_ref().map_or(0, |_| 1) +
398            self.empty_dir.as_ref().map_or(0, |_| 1) +
399            self.ephemeral.as_ref().map_or(0, |_| 1) +
400            self.fc.as_ref().map_or(0, |_| 1) +
401            self.flex_volume.as_ref().map_or(0, |_| 1) +
402            self.flocker.as_ref().map_or(0, |_| 1) +
403            self.gce_persistent_disk.as_ref().map_or(0, |_| 1) +
404            self.git_repo.as_ref().map_or(0, |_| 1) +
405            self.glusterfs.as_ref().map_or(0, |_| 1) +
406            self.host_path.as_ref().map_or(0, |_| 1) +
407            self.iscsi.as_ref().map_or(0, |_| 1) +
408            self.nfs.as_ref().map_or(0, |_| 1) +
409            self.persistent_volume_claim.as_ref().map_or(0, |_| 1) +
410            self.photon_persistent_disk.as_ref().map_or(0, |_| 1) +
411            self.portworx_volume.as_ref().map_or(0, |_| 1) +
412            self.projected.as_ref().map_or(0, |_| 1) +
413            self.quobyte.as_ref().map_or(0, |_| 1) +
414            self.rbd.as_ref().map_or(0, |_| 1) +
415            self.scale_io.as_ref().map_or(0, |_| 1) +
416            self.secret.as_ref().map_or(0, |_| 1) +
417            self.storageos.as_ref().map_or(0, |_| 1) +
418            self.vsphere_volume.as_ref().map_or(0, |_| 1),
419        )?;
420        if let Some(value) = &self.aws_elastic_block_store {
421            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "awsElasticBlockStore", value)?;
422        }
423        if let Some(value) = &self.azure_disk {
424            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "azureDisk", value)?;
425        }
426        if let Some(value) = &self.azure_file {
427            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "azureFile", value)?;
428        }
429        if let Some(value) = &self.cephfs {
430            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "cephfs", value)?;
431        }
432        if let Some(value) = &self.cinder {
433            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "cinder", value)?;
434        }
435        if let Some(value) = &self.config_map {
436            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "configMap", value)?;
437        }
438        if let Some(value) = &self.csi {
439            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "csi", value)?;
440        }
441        if let Some(value) = &self.downward_api {
442            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "downwardAPI", value)?;
443        }
444        if let Some(value) = &self.empty_dir {
445            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "emptyDir", value)?;
446        }
447        if let Some(value) = &self.ephemeral {
448            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ephemeral", value)?;
449        }
450        if let Some(value) = &self.fc {
451            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fc", value)?;
452        }
453        if let Some(value) = &self.flex_volume {
454            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "flexVolume", value)?;
455        }
456        if let Some(value) = &self.flocker {
457            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "flocker", value)?;
458        }
459        if let Some(value) = &self.gce_persistent_disk {
460            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gcePersistentDisk", value)?;
461        }
462        if let Some(value) = &self.git_repo {
463            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gitRepo", value)?;
464        }
465        if let Some(value) = &self.glusterfs {
466            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "glusterfs", value)?;
467        }
468        if let Some(value) = &self.host_path {
469            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostPath", value)?;
470        }
471        if let Some(value) = &self.iscsi {
472            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "iscsi", value)?;
473        }
474        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
475        if let Some(value) = &self.nfs {
476            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nfs", value)?;
477        }
478        if let Some(value) = &self.persistent_volume_claim {
479            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "persistentVolumeClaim", value)?;
480        }
481        if let Some(value) = &self.photon_persistent_disk {
482            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "photonPersistentDisk", value)?;
483        }
484        if let Some(value) = &self.portworx_volume {
485            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "portworxVolume", value)?;
486        }
487        if let Some(value) = &self.projected {
488            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "projected", value)?;
489        }
490        if let Some(value) = &self.quobyte {
491            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "quobyte", value)?;
492        }
493        if let Some(value) = &self.rbd {
494            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "rbd", value)?;
495        }
496        if let Some(value) = &self.scale_io {
497            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "scaleIO", value)?;
498        }
499        if let Some(value) = &self.secret {
500            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secret", value)?;
501        }
502        if let Some(value) = &self.storageos {
503            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storageos", value)?;
504        }
505        if let Some(value) = &self.vsphere_volume {
506            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "vsphereVolume", value)?;
507        }
508        crate::serde::ser::SerializeStruct::end(state)
509    }
510}
511
512#[cfg(feature = "schemars")]
513impl crate::schemars::JsonSchema for Volume {
514    fn schema_name() -> std::borrow::Cow<'static, str> {
515        "io.k8s.api.core.v1.Volume".into()
516    }
517
518    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
519        crate::schemars::json_schema!({
520            "description": "Volume represents a named volume in a pod that may be accessed by any container in the pod.",
521            "type": "object",
522            "properties": {
523                "awsElasticBlockStore": ({
524                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::AWSElasticBlockStoreVolumeSource>();
525                    schema_obj.ensure_object().insert("description".into(), "awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore".into());
526                    schema_obj
527                }),
528                "azureDisk": ({
529                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::AzureDiskVolumeSource>();
530                    schema_obj.ensure_object().insert("description".into(), "azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod.".into());
531                    schema_obj
532                }),
533                "azureFile": ({
534                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::AzureFileVolumeSource>();
535                    schema_obj.ensure_object().insert("description".into(), "azureFile represents an Azure File Service mount on the host and bind mount to the pod.".into());
536                    schema_obj
537                }),
538                "cephfs": ({
539                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::CephFSVolumeSource>();
540                    schema_obj.ensure_object().insert("description".into(), "cephFS represents a Ceph FS mount on the host that shares a pod's lifetime".into());
541                    schema_obj
542                }),
543                "cinder": ({
544                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::CinderVolumeSource>();
545                    schema_obj.ensure_object().insert("description".into(), "cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md".into());
546                    schema_obj
547                }),
548                "configMap": ({
549                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ConfigMapVolumeSource>();
550                    schema_obj.ensure_object().insert("description".into(), "configMap represents a configMap that should populate this volume".into());
551                    schema_obj
552                }),
553                "csi": ({
554                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::CSIVolumeSource>();
555                    schema_obj.ensure_object().insert("description".into(), "csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).".into());
556                    schema_obj
557                }),
558                "downwardAPI": ({
559                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::DownwardAPIVolumeSource>();
560                    schema_obj.ensure_object().insert("description".into(), "downwardAPI represents downward API about the pod that should populate this volume".into());
561                    schema_obj
562                }),
563                "emptyDir": ({
564                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::EmptyDirVolumeSource>();
565                    schema_obj.ensure_object().insert("description".into(), "emptyDir represents a temporary directory that shares a pod's lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir".into());
566                    schema_obj
567                }),
568                "ephemeral": ({
569                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::EphemeralVolumeSource>();
570                    schema_obj.ensure_object().insert("description".into(), "ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed.\n\nUse this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity\n   tracking are needed,\nc) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through\n   a PersistentVolumeClaim (see EphemeralVolumeSource for more\n   information on the connection between this volume type\n   and PersistentVolumeClaim).\n\nUse PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod.\n\nUse CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information.\n\nA pod can use both types of ephemeral volumes and persistent volumes at the same time.".into());
571                    schema_obj
572                }),
573                "fc": ({
574                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::FCVolumeSource>();
575                    schema_obj.ensure_object().insert("description".into(), "fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.".into());
576                    schema_obj
577                }),
578                "flexVolume": ({
579                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::FlexVolumeSource>();
580                    schema_obj.ensure_object().insert("description".into(), "flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.".into());
581                    schema_obj
582                }),
583                "flocker": ({
584                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::FlockerVolumeSource>();
585                    schema_obj.ensure_object().insert("description".into(), "flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running".into());
586                    schema_obj
587                }),
588                "gcePersistentDisk": ({
589                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::GCEPersistentDiskVolumeSource>();
590                    schema_obj.ensure_object().insert("description".into(), "gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk".into());
591                    schema_obj
592                }),
593                "gitRepo": ({
594                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::GitRepoVolumeSource>();
595                    schema_obj.ensure_object().insert("description".into(), "gitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.".into());
596                    schema_obj
597                }),
598                "glusterfs": ({
599                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::GlusterfsVolumeSource>();
600                    schema_obj.ensure_object().insert("description".into(), "glusterfs represents a Glusterfs mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md".into());
601                    schema_obj
602                }),
603                "hostPath": ({
604                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::HostPathVolumeSource>();
605                    schema_obj.ensure_object().insert("description".into(), "hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath".into());
606                    schema_obj
607                }),
608                "iscsi": ({
609                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ISCSIVolumeSource>();
610                    schema_obj.ensure_object().insert("description".into(), "iscsi represents an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md".into());
611                    schema_obj
612                }),
613                "name": {
614                    "description": "name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
615                    "type": "string",
616                },
617                "nfs": ({
618                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NFSVolumeSource>();
619                    schema_obj.ensure_object().insert("description".into(), "nfs represents an NFS mount on the host that shares a pod's lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs".into());
620                    schema_obj
621                }),
622                "persistentVolumeClaim": ({
623                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PersistentVolumeClaimVolumeSource>();
624                    schema_obj.ensure_object().insert("description".into(), "persistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims".into());
625                    schema_obj
626                }),
627                "photonPersistentDisk": ({
628                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PhotonPersistentDiskVolumeSource>();
629                    schema_obj.ensure_object().insert("description".into(), "photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine".into());
630                    schema_obj
631                }),
632                "portworxVolume": ({
633                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PortworxVolumeSource>();
634                    schema_obj.ensure_object().insert("description".into(), "portworxVolume represents a portworx volume attached and mounted on kubelets host machine".into());
635                    schema_obj
636                }),
637                "projected": ({
638                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ProjectedVolumeSource>();
639                    schema_obj.ensure_object().insert("description".into(), "projected items for all in one resources secrets, configmaps, and downward API".into());
640                    schema_obj
641                }),
642                "quobyte": ({
643                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::QuobyteVolumeSource>();
644                    schema_obj.ensure_object().insert("description".into(), "quobyte represents a Quobyte mount on the host that shares a pod's lifetime".into());
645                    schema_obj
646                }),
647                "rbd": ({
648                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::RBDVolumeSource>();
649                    schema_obj.ensure_object().insert("description".into(), "rbd represents a Rados Block Device mount on the host that shares a pod's lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md".into());
650                    schema_obj
651                }),
652                "scaleIO": ({
653                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ScaleIOVolumeSource>();
654                    schema_obj.ensure_object().insert("description".into(), "scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.".into());
655                    schema_obj
656                }),
657                "secret": ({
658                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretVolumeSource>();
659                    schema_obj.ensure_object().insert("description".into(), "secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret".into());
660                    schema_obj
661                }),
662                "storageos": ({
663                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::StorageOSVolumeSource>();
664                    schema_obj.ensure_object().insert("description".into(), "storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.".into());
665                    schema_obj
666                }),
667                "vsphereVolume": ({
668                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::VsphereVirtualDiskVolumeSource>();
669                    schema_obj.ensure_object().insert("description".into(), "vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine".into());
670                    schema_obj
671                }),
672            },
673            "required": [
674                "name",
675            ],
676        })
677    }
678}