On 2/23/24 15:27, Stefan Lendl wrote:
Aaron Lauterer <a.laute...@proxmox.com> writes:

+#[derive(Clone, Deserialize, Debug)]
+pub struct Disks {
+    pub filesystem: Option<Filesystem>,
+    pub disk_selection: Option<Vec<String>>,
+    pub filter_match: Option<FilterMatch>,
+    // use BTreeMap to have keys sorted
+    pub filter: Option<BTreeMap<String, String>>,
+    pub zfs: Option<ZfsOptions>,
+    pub lvm: Option<LvmOptions>,
+    pub btrfs: Option<BtrfsOptions>,
+}

instead of individual zfs, lvm and btrfs options you could have an enum
like this.

enum FsOptions{
      Zfs(ZfsOptions),
      Lvm(LvmOptions),
      Btrfs(BtrfsOptions),
      None,
}

This would also serve the purpose of the Filesystem prop.

Thanks for the feedback! The main purpose here is to define the layout of the 
answer.toml file. While these would result in nicer data structures, I don't 
see how we could keep the current layout of the answer file we parse. I'll keep 
it in mind and see if it is possible to massage the current format into nicer 
structures.


+
+#[derive(Clone, Deserialize, Debug, PartialEq)]
+#[serde(rename_all = "lowercase")]
+pub enum FilterMatch {
+    Any,
+    All,
+}
+
+#[derive(Clone, Deserialize, Serialize, Debug)]
+#[serde(rename_all = "kebab-case")]
+pub enum Filesystem {
+    Ext4,
+    Xfs,
+    ZfsRaid0,
+    ZfsRaid1,
+    ZfsRaid10,
+    ZfsRaidZ1,
+    ZfsRaidZ2,
+    ZfsRaidZ3,
+    BtrfsRaid0,
+    BtrfsRaid1,
+    BtrfsRaid10,
+}

This could also be sth like:
Zfs { toplogy: ZfsTopolgy, options: ZfsOptions },
Btrfs { toplogy: BtrfsTopology, options: BtrfsOptions },
...


+
+#[derive(Clone, Deserialize, Debug)]
+pub struct ZfsOptions {
+    pub ashift: Option<usize>,
+    pub arc_max: Option<usize>,
+    pub checksum: Option<ZfsChecksumOption>,
+    pub compress: Option<ZfsCompressOption>,
+    pub copies: Option<usize>,
+    pub hdsize: Option<f64>,
+}
+
+impl ZfsOptions {
+    pub fn new() -> ZfsOptions {
+        ZfsOptions {
+            ashift: None,
+            arc_max: None,
+            checksum: None,
+            compress: None,
+            copies: None,
+            hdsize: None,
+        }
+    }
+}
+
+#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Deserialize)]
+#[serde(rename_all(deserialize = "lowercase"))]
+pub enum ZfsCompressOption {
+    #[default]
+    On,
+    Off,
+    Lzjb,
+    Lz4,
+    Zle,
+    Gzip,
+    Zstd,
+}
+


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to