edge_schema/schema/
fs.rs

1use bytesize::ByteSize;
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5use super::Merge;
6
7#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
8pub struct CapabilityFileSystemV1 {
9    #[serde(default)]
10    pub volumes: Vec<FsVolumeConfig>,
11}
12
13impl Merge for CapabilityFileSystemV1 {
14    fn merge_extend(mut self, other: &Self) -> Self {
15        self.volumes.extend(other.volumes.clone());
16        self
17    }
18}
19
20#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
21pub struct FsVolumeConfig {
22    /// Name for the volume in the context of this workload.
23    pub name: String,
24    pub source: VolumeSourceV1,
25    pub mounts: Vec<VolumeMountV1>,
26}
27
28#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
29#[serde(rename_all = "snake_case")]
30pub enum VolumeSourceV1 {
31    Shared(VolumeSourceShared),
32}
33
34#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
35pub struct VolumeSourceShared {
36    pub id: Uuid,
37    /// Maximum size of the volume.
38    #[schemars(with = "Option<String>")]
39    pub size: Option<ByteSize>,
40}
41
42#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
43pub struct VolumeMountV1 {
44    /// The path where the volume should be mounted.
45    pub mount_path: String,
46    /// Subdirectory of the volume to mount.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub sub_path: Option<String>,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub permissions: Option<FsPermissionsV1>,
51}
52
53#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
54pub struct FsPermissionsV1 {
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub read: Option<bool>,
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub write: Option<bool>,
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub delete: Option<bool>,
61}