-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style: clarify answers.toml
format
#11
Open
duesee
wants to merge
2
commits into
proxmox:master
Choose a base branch
from
duesee:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ use std::{collections::BTreeMap, net::IpAddr}; | |
// BTreeMap is used to store filters as the order of the filters will be stable, compared to | ||
// storing them in a HashMap | ||
|
||
// ----- Start of `answers.toml` format definition ----- | ||
|
||
#[derive(Clone, Deserialize, Debug)] | ||
#[serde(rename_all = "kebab-case", deny_unknown_fields)] | ||
pub struct Answer { | ||
|
@@ -34,6 +36,48 @@ pub struct Global { | |
pub root_ssh_keys: Vec<String>, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
#[serde(rename_all = "kebab-case", deny_unknown_fields)] | ||
pub enum KeyboardLayout { | ||
De, | ||
DeCh, | ||
Dk, | ||
EnGb, | ||
EnUs, | ||
Es, | ||
Fi, | ||
Fr, | ||
FrBe, | ||
FrCa, | ||
FrCh, | ||
Hu, | ||
Is, | ||
It, | ||
Jp, | ||
Lt, | ||
Mk, | ||
Nl, | ||
No, | ||
Pl, | ||
Pt, | ||
PtBr, | ||
Se, | ||
Si, | ||
Tr, | ||
} | ||
|
||
// This is the format in `answers.toml` because `Network` is constructed from `NetworkInAnswer`. | ||
#[derive(Clone, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
struct NetworkInAnswer { | ||
#[serde(default)] | ||
pub source: NetworkConfigMode, | ||
pub cidr: Option<CidrAddress>, | ||
pub dns: Option<IpAddr>, | ||
pub gateway: Option<IpAddr>, | ||
pub filter: Option<BTreeMap<String, String>>, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Debug, Default, PartialEq)] | ||
#[serde(deny_unknown_fields)] | ||
enum NetworkConfigMode { | ||
|
@@ -44,23 +88,87 @@ enum NetworkConfigMode { | |
FromAnswer, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Debug)] | ||
// This is the format in `answers.toml` because `Disks` is constructed from `DiskSetup`. | ||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
struct NetworkInAnswer { | ||
pub struct DiskSetup { | ||
pub filesystem: Filesystem, | ||
#[serde(default)] | ||
pub source: NetworkConfigMode, | ||
pub cidr: Option<CidrAddress>, | ||
pub dns: Option<IpAddr>, | ||
pub gateway: Option<IpAddr>, | ||
pub disk_list: Vec<String>, | ||
pub filter: Option<BTreeMap<String, String>>, | ||
pub filter_match: Option<FilterMatch>, | ||
pub btrfs: Option<BtrfsOptions>, | ||
pub lvm: Option<LvmOptions>, | ||
pub zfs: Option<ZfsOptions>, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
#[serde(rename_all = "lowercase", deny_unknown_fields)] | ||
pub enum Filesystem { | ||
Btrfs, | ||
Ext4, | ||
Xfs, | ||
Zfs, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Debug, PartialEq, ValueEnum)] | ||
#[serde(rename_all = "lowercase", deny_unknown_fields)] | ||
pub enum FilterMatch { | ||
Any, | ||
All, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct BtrfsOptions { | ||
pub hdsize: Option<f64>, | ||
pub raid: Option<BtrfsRaidLevel>, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Serialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct LvmOptions { | ||
pub hdsize: Option<f64>, | ||
pub swapsize: Option<f64>, | ||
pub maxroot: Option<f64>, | ||
pub maxvz: Option<f64>, | ||
pub minfree: Option<f64>, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct ZfsOptions { | ||
pub raid: Option<ZfsRaidLevel>, | ||
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>, | ||
} | ||
|
||
// ----- End of `answers.toml` format definition ----- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After this line, there is no "external API" anymore. |
||
|
||
#[derive(Clone, Deserialize, Debug)] | ||
#[serde(try_from = "NetworkInAnswer", deny_unknown_fields)] | ||
pub struct Network { | ||
pub network_settings: NetworkSettings, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum NetworkSettings { | ||
FromDhcp, | ||
Manual(NetworkManual), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct NetworkManual { | ||
pub cidr: CidrAddress, | ||
pub dns: IpAddr, | ||
pub gateway: IpAddr, | ||
pub filter: BTreeMap<String, String>, | ||
} | ||
|
||
impl TryFrom<NetworkInAnswer> for Network { | ||
type Error = &'static str; | ||
|
||
|
@@ -108,33 +216,6 @@ impl TryFrom<NetworkInAnswer> for Network { | |
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum NetworkSettings { | ||
FromDhcp, | ||
Manual(NetworkManual), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct NetworkManual { | ||
pub cidr: CidrAddress, | ||
pub dns: IpAddr, | ||
pub gateway: IpAddr, | ||
pub filter: BTreeMap<String, String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct DiskSetup { | ||
pub filesystem: Filesystem, | ||
#[serde(default)] | ||
pub disk_list: Vec<String>, | ||
pub filter: Option<BTreeMap<String, String>>, | ||
pub filter_match: Option<FilterMatch>, | ||
pub zfs: Option<ZfsOptions>, | ||
pub lvm: Option<LvmOptions>, | ||
pub btrfs: Option<BtrfsOptions>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(try_from = "DiskSetup", deny_unknown_fields)] | ||
pub struct Disks { | ||
|
@@ -144,6 +225,19 @@ pub struct Disks { | |
pub fs_options: FsOptions, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum DiskSelection { | ||
Selection(Vec<String>), | ||
Filter(BTreeMap<String, String>), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum FsOptions { | ||
BTRFS(BtrfsOptions), | ||
LVM(LvmOptions), | ||
ZFS(ZfsOptions), | ||
} | ||
|
||
impl TryFrom<DiskSetup> for Disks { | ||
type Error = &'static str; | ||
|
||
|
@@ -215,91 +309,4 @@ impl TryFrom<DiskSetup> for Disks { | |
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum FsOptions { | ||
LVM(LvmOptions), | ||
ZFS(ZfsOptions), | ||
BTRFS(BtrfsOptions), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum DiskSelection { | ||
Selection(Vec<String>), | ||
Filter(BTreeMap<String, String>), | ||
} | ||
#[derive(Clone, Deserialize, Debug, PartialEq, ValueEnum)] | ||
#[serde(rename_all = "lowercase", deny_unknown_fields)] | ||
pub enum FilterMatch { | ||
Any, | ||
All, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
#[serde(rename_all = "lowercase", deny_unknown_fields)] | ||
pub enum Filesystem { | ||
Ext4, | ||
Xfs, | ||
Zfs, | ||
Btrfs, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct ZfsOptions { | ||
pub raid: Option<ZfsRaidLevel>, | ||
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>, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Serialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct LvmOptions { | ||
pub hdsize: Option<f64>, | ||
pub swapsize: Option<f64>, | ||
pub maxroot: Option<f64>, | ||
pub maxvz: Option<f64>, | ||
pub minfree: Option<f64>, | ||
} | ||
|
||
#[derive(Clone, Copy, Default, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct BtrfsOptions { | ||
pub hdsize: Option<f64>, | ||
pub raid: Option<BtrfsRaidLevel>, | ||
} | ||
|
||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)] | ||
#[serde(rename_all = "kebab-case", deny_unknown_fields)] | ||
pub enum KeyboardLayout { | ||
De, | ||
DeCh, | ||
Dk, | ||
EnGb, | ||
EnUs, | ||
Es, | ||
Fi, | ||
Fr, | ||
FrBe, | ||
FrCa, | ||
FrCh, | ||
Hu, | ||
Is, | ||
It, | ||
Jp, | ||
Lt, | ||
Mk, | ||
Nl, | ||
No, | ||
Pl, | ||
Pt, | ||
PtBr, | ||
Se, | ||
Si, | ||
Tr, | ||
} | ||
|
||
serde_plain::derive_display_from_serialize!(KeyboardLayout); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ | |
"country": "at", | ||
"dns": "192.168.1.254", | ||
"domain": "testinstall", | ||
"existing_storage_auto_rename": 1, | ||
"filesys": "ext4", | ||
"gateway": "192.168.1.1", | ||
"hdsize": 223.57088470458984, | ||
"lvm_auto_rename": 1, | ||
"hostname": "pveauto", | ||
"keymap": "de", | ||
"mailto": "[email protected]", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved here from bottom so that
Global
is fully defined after line 67.