mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-04-28 04:44:59 +00:00
tree-wide: rust: run cargo fmt
The 2024 style guide changed some things, which causes quite some churn. Most of boils down to the changed import order, now choosing types before function items - which is the other way round then before. No functional changes. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
c305be5e91
commit
a1575df428
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use anyhow::{Result, bail, format_err};
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
use glob::Pattern;
|
||||
use serde::Serialize;
|
||||
@ -14,9 +14,9 @@ use proxmox_auto_installer::{
|
||||
answer::{Answer, FilterMatch},
|
||||
sysinfo::SysInfo,
|
||||
utils::{
|
||||
get_matched_udev_indexes, get_nic_list, get_single_udev_index,
|
||||
verify_email_and_root_password_settings, verify_first_boot_settings,
|
||||
verify_locale_settings, AutoInstSettings, FetchAnswerFrom, HttpOptions,
|
||||
AutoInstSettings, FetchAnswerFrom, HttpOptions, get_matched_udev_indexes, get_nic_list,
|
||||
get_single_udev_index, verify_email_and_root_password_settings, verify_first_boot_settings,
|
||||
verify_locale_settings,
|
||||
},
|
||||
};
|
||||
use proxmox_installer_common::{FIRST_BOOT_EXEC_MAX_SIZE, FIRST_BOOT_EXEC_NAME};
|
||||
@ -624,7 +624,9 @@ fn check_prepare_requirements(args: &CommandPrepareISO) -> Result<()> {
|
||||
{
|
||||
Ok(v) => {
|
||||
if !v.success() {
|
||||
bail!("The source ISO file is not able to be installed automatically. Please try a more current one.");
|
||||
bail!(
|
||||
"The source ISO file is not able to be installed automatically. Please try a more current one."
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{format_err, Result};
|
||||
use anyhow::{Result, format_err};
|
||||
use clap::ValueEnum;
|
||||
use proxmox_installer_common::{
|
||||
options::{
|
||||
@ -280,7 +280,7 @@ impl TryFrom<DiskSetup> for Disks {
|
||||
}
|
||||
match source.zfs {
|
||||
None | Some(ZfsOptions { raid: None, .. }) => {
|
||||
return Err("ZFS raid level 'zfs.raid' must be set")
|
||||
return Err("ZFS raid level 'zfs.raid' must be set");
|
||||
}
|
||||
Some(opts) => (FsType::Zfs(opts.raid.unwrap()), FsOptions::ZFS(opts)),
|
||||
}
|
||||
@ -291,7 +291,7 @@ impl TryFrom<DiskSetup> for Disks {
|
||||
}
|
||||
match source.btrfs {
|
||||
None | Some(BtrfsOptions { raid: None, .. }) => {
|
||||
return Err("BTRFS raid level 'btrfs.raid' must be set")
|
||||
return Err("BTRFS raid level 'btrfs.raid' must be set");
|
||||
}
|
||||
Some(opts) => (FsType::Btrfs(opts.raid.unwrap()), FsOptions::BTRFS(opts)),
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use log::{error, info, LevelFilter};
|
||||
use anyhow::{Result, bail, format_err};
|
||||
use log::{LevelFilter, error, info};
|
||||
use std::{
|
||||
env,
|
||||
fs::{self, File},
|
||||
@ -9,12 +9,11 @@ use std::{
|
||||
};
|
||||
|
||||
use proxmox_installer_common::{
|
||||
http,
|
||||
FIRST_BOOT_EXEC_MAX_SIZE, FIRST_BOOT_EXEC_NAME, RUNTIME_DIR, http,
|
||||
setup::{
|
||||
installer_setup, read_json, spawn_low_level_installer, LocaleInfo, LowLevelMessage,
|
||||
RuntimeInfo, SetupInfo,
|
||||
LocaleInfo, LowLevelMessage, RuntimeInfo, SetupInfo, installer_setup, read_json,
|
||||
spawn_low_level_installer,
|
||||
},
|
||||
FIRST_BOOT_EXEC_MAX_SIZE, FIRST_BOOT_EXEC_NAME, RUNTIME_DIR,
|
||||
};
|
||||
|
||||
use proxmox_auto_installer::{
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use log::{Level, Metadata, Record};
|
||||
use std::{fs::File, io::Write, sync::Mutex, sync::OnceLock};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use proxmox_installer_common::{
|
||||
RUNTIME_DIR,
|
||||
setup::{IsoInfo, ProductConfig, SetupInfo},
|
||||
sysinfo::SystemDMI,
|
||||
RUNTIME_DIR,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use std::{fs, io, path::PathBuf};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, Context, Result};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use clap::ValueEnum;
|
||||
use glob::Pattern;
|
||||
use log::info;
|
||||
@ -9,12 +9,12 @@ use crate::{
|
||||
udevinfo::UdevInfo,
|
||||
};
|
||||
use proxmox_installer_common::{
|
||||
options::{email_validate, FsType, NetworkOptions, ZfsChecksumOption, ZfsCompressOption},
|
||||
ROOT_PASSWORD_MIN_LENGTH,
|
||||
options::{FsType, NetworkOptions, ZfsChecksumOption, ZfsCompressOption, email_validate},
|
||||
setup::{
|
||||
InstallBtrfsOption, InstallConfig, InstallFirstBootSetup, InstallRootPassword,
|
||||
InstallZfsOption, LocaleInfo, RuntimeInfo, SetupInfo,
|
||||
},
|
||||
ROOT_PASSWORD_MIN_LENGTH,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -286,7 +286,9 @@ fn verify_filesystem_settings(answer: &Answer, setup_info: &SetupInfo) -> Result
|
||||
info!("Verifying filesystem settings");
|
||||
|
||||
if answer.disks.fs_type.is_btrfs() && !setup_info.config.enable_btrfs {
|
||||
bail!("BTRFS is not supported as a root filesystem for the product or the release of this ISO.");
|
||||
bail!(
|
||||
"BTRFS is not supported as a root filesystem for the product or the release of this ISO."
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -339,13 +341,17 @@ pub fn verify_email_and_root_password_settings(answer: &Answer) -> Result<()> {
|
||||
&answer.global.root_password_hashed,
|
||||
) {
|
||||
(Some(_), Some(_)) => {
|
||||
bail!("`global.root_password` and `global.root_password_hashed` cannot be set at the same time");
|
||||
bail!(
|
||||
"`global.root_password` and `global.root_password_hashed` cannot be set at the same time"
|
||||
);
|
||||
}
|
||||
(None, None) => {
|
||||
bail!("One of `global.root_password` or `global.root_password_hashed` must be set");
|
||||
}
|
||||
(Some(password), None) if password.len() < ROOT_PASSWORD_MIN_LENGTH => {
|
||||
bail!("`global.root_password` must be at least {ROOT_PASSWORD_MIN_LENGTH} characters long");
|
||||
bail!(
|
||||
"`global.root_password` must be at least {ROOT_PASSWORD_MIN_LENGTH} characters long"
|
||||
);
|
||||
}
|
||||
_ => Ok(()),
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use proxmox_auto_installer::udevinfo::UdevInfo;
|
||||
use proxmox_auto_installer::utils::parse_answer;
|
||||
|
||||
use proxmox_installer_common::setup::{
|
||||
load_installer_setup_files, read_json, LocaleInfo, RuntimeInfo, SetupInfo,
|
||||
LocaleInfo, RuntimeInfo, SetupInfo, load_installer_setup_files, read_json,
|
||||
};
|
||||
|
||||
fn get_test_resource_path() -> Result<PathBuf, String> {
|
||||
|
@ -4,13 +4,13 @@ use std::{
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
use nix::mount::{mount, umount, MsFlags};
|
||||
use nix::mount::{MsFlags, mount, umount};
|
||||
use proxmox_installer_common::{
|
||||
RUNTIME_DIR,
|
||||
options::FsType,
|
||||
setup::{InstallConfig, SetupInfo},
|
||||
RUNTIME_DIR,
|
||||
};
|
||||
use regex::Regex;
|
||||
|
||||
@ -132,7 +132,9 @@ fn get_fs(filesystem: Option<Filesystems>) -> Result<Filesystems> {
|
||||
None => {
|
||||
let low_level_config = match get_low_level_config() {
|
||||
Ok(c) => c,
|
||||
Err(_) => bail!("Could not fetch config from previous installation. Please specify file system with -f."),
|
||||
Err(_) => bail!(
|
||||
"Could not fetch config from previous installation. Please specify file system with -f."
|
||||
),
|
||||
};
|
||||
Filesystems::from(low_level_config.filesys)
|
||||
}
|
||||
@ -292,7 +294,9 @@ fn get_btrfs_uuid() -> Result<String> {
|
||||
let uuid_list = uuids
|
||||
.iter()
|
||||
.fold(String::new(), |acc, &arg| format!("{acc}\n{arg}"));
|
||||
bail!("Found {i} UUIDs:{uuid_list}\nPlease specify the UUID to use with the --btrfs-uuid parameter")
|
||||
bail!(
|
||||
"Found {i} UUIDs:{uuid_list}\nPlease specify the UUID to use with the --btrfs-uuid parameter"
|
||||
)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use log::info;
|
||||
use serde::Serialize;
|
||||
use std::{
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use anyhow::{Result, bail, format_err};
|
||||
use log::{info, warn};
|
||||
use std::{
|
||||
fs::{self, create_dir_all},
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::process::ExitCode;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use log::{error, info, LevelFilter};
|
||||
use anyhow::{Result, bail, format_err};
|
||||
use log::{LevelFilter, error, info};
|
||||
|
||||
use proxmox_auto_installer::{
|
||||
log::AutoInstLogger,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
process::{self, Command, Stdio},
|
||||
};
|
||||
|
||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
|
||||
|
||||
use crate::{
|
||||
options::{
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{collections::HashMap, fs};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{Result, bail};
|
||||
use serde::Serialize;
|
||||
|
||||
const DMI_PATH: &str = "/sys/devices/virtual/dmi/id";
|
||||
|
@ -117,11 +117,7 @@ impl<'de> Deserialize<'de> for CidrAddress {
|
||||
serde_plain::derive_serialize_from_display!(CidrAddress);
|
||||
|
||||
fn mask_limit(addr: &IpAddr) -> usize {
|
||||
if addr.is_ipv4() {
|
||||
32
|
||||
} else {
|
||||
128
|
||||
}
|
||||
if addr.is_ipv4() { 32 } else { 128 }
|
||||
}
|
||||
|
||||
/// Possible errors that might occur when parsing FQDNs.
|
||||
|
@ -19,7 +19,7 @@ use std::{
|
||||
process::{Command, ExitCode},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use proxmox_auto_installer::{
|
||||
answer::{Answer, PostNotificationHookInfo},
|
||||
udevinfo::{UdevInfo, UdevProperties},
|
||||
@ -27,8 +27,8 @@ use proxmox_auto_installer::{
|
||||
use proxmox_installer_common::{
|
||||
options::{Disk, FsType},
|
||||
setup::{
|
||||
load_installer_setup_files, BootType, InstallConfig, IsoInfo, ProxmoxProduct, RuntimeInfo,
|
||||
SetupInfo,
|
||||
BootType, InstallConfig, IsoInfo, ProxmoxProduct, RuntimeInfo, SetupInfo,
|
||||
load_installer_setup_files,
|
||||
},
|
||||
sysinfo::SystemDMI,
|
||||
utils::CidrAddress,
|
||||
|
@ -3,6 +3,7 @@
|
||||
use std::{collections::HashMap, env, net::IpAddr};
|
||||
|
||||
use cursive::{
|
||||
Cursive, CursiveRunnable, ScreenId, View, XY,
|
||||
event::Event,
|
||||
theme::{ColorStyle, Effect, Effects, PaletteColor, Style},
|
||||
view::{Nameable, Offset, Resizable, ViewWrapper},
|
||||
@ -10,17 +11,16 @@ use cursive::{
|
||||
Button, Checkbox, Dialog, DummyView, EditView, Layer, LinearLayout, PaddedView, Panel,
|
||||
ResizedView, ScrollView, SelectView, StackView, TextView,
|
||||
},
|
||||
Cursive, CursiveRunnable, ScreenId, View, XY,
|
||||
};
|
||||
|
||||
mod options;
|
||||
use options::{InstallerOptions, PasswordOptions};
|
||||
|
||||
use proxmox_installer_common::{
|
||||
options::{email_validate, BootdiskOptions, NetworkOptions, TimezoneOptions},
|
||||
setup::{installer_setup, LocaleInfo, ProxmoxProduct, RuntimeInfo, SetupInfo},
|
||||
utils::Fqdn,
|
||||
ROOT_PASSWORD_MIN_LENGTH,
|
||||
options::{BootdiskOptions, NetworkOptions, TimezoneOptions, email_validate},
|
||||
setup::{LocaleInfo, ProxmoxProduct, RuntimeInfo, SetupInfo, installer_setup},
|
||||
utils::Fqdn,
|
||||
};
|
||||
|
||||
mod setup;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::SummaryOption;
|
||||
|
||||
use proxmox_installer_common::{
|
||||
EMAIL_DEFAULT_PLACEHOLDER,
|
||||
options::{
|
||||
BootdiskOptions, BtrfsRaidLevel, FsType, NetworkOptions, TimezoneOptions, ZfsRaidLevel,
|
||||
},
|
||||
setup::LocaleInfo,
|
||||
EMAIL_DEFAULT_PLACEHOLDER,
|
||||
};
|
||||
|
||||
pub const FS_TYPES: &[FsType] = {
|
||||
@ -103,7 +103,7 @@ mod tests {
|
||||
state: InterfaceState::Up,
|
||||
mac: "01:23:45:67:89:ab".to_owned(),
|
||||
addresses: Some(vec![
|
||||
CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap()
|
||||
CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
|
||||
]),
|
||||
},
|
||||
);
|
||||
|
@ -4,17 +4,17 @@ use std::{
|
||||
};
|
||||
|
||||
use cursive::{
|
||||
Cursive, Vec2, View,
|
||||
view::{Nameable, Resizable, ViewWrapper},
|
||||
views::{
|
||||
Button, Dialog, DummyView, LinearLayout, NamedView, PaddedView, Panel, ScrollView,
|
||||
SelectView, TextView, ViewRef,
|
||||
},
|
||||
Cursive, Vec2, View,
|
||||
};
|
||||
|
||||
use super::{DiskSizeEditView, FormView, IntegerEditView, TabbedView};
|
||||
use crate::options::FS_TYPES;
|
||||
use crate::InstallerState;
|
||||
use crate::options::FS_TYPES;
|
||||
|
||||
use proxmox_installer_common::{
|
||||
disk_checks::{
|
||||
@ -22,9 +22,9 @@ use proxmox_installer_common::{
|
||||
check_zfs_raid_config,
|
||||
},
|
||||
options::{
|
||||
AdvancedBootdiskOptions, BootdiskOptions, BtrfsBootdiskOptions, Disk, FsType,
|
||||
LvmBootdiskOptions, ZfsBootdiskOptions, BTRFS_COMPRESS_OPTIONS, ZFS_CHECKSUM_OPTIONS,
|
||||
ZFS_COMPRESS_OPTIONS,
|
||||
AdvancedBootdiskOptions, BTRFS_COMPRESS_OPTIONS, BootdiskOptions, BtrfsBootdiskOptions,
|
||||
Disk, FsType, LvmBootdiskOptions, ZFS_CHECKSUM_OPTIONS, ZFS_COMPRESS_OPTIONS,
|
||||
ZfsBootdiskOptions,
|
||||
},
|
||||
setup::{BootType, ProductConfig, ProxmoxProduct, RuntimeInfo},
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
use cursive::{
|
||||
CbSink, Cursive,
|
||||
utils::Counter,
|
||||
view::{Nameable, Resizable, ViewWrapper},
|
||||
views::{Dialog, DummyView, LinearLayout, PaddedView, ProgressBar, TextView},
|
||||
CbSink, Cursive,
|
||||
};
|
||||
use std::{
|
||||
fs::File,
|
||||
@ -12,8 +12,8 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::{abort_install_button, prompt_dialog, InstallerState};
|
||||
use proxmox_installer_common::setup::{spawn_low_level_installer, InstallConfig, LowLevelMessage};
|
||||
use crate::{InstallerState, abort_install_button, prompt_dialog};
|
||||
use proxmox_installer_common::setup::{InstallConfig, LowLevelMessage, spawn_low_level_installer};
|
||||
|
||||
pub struct InstallProgressView {
|
||||
view: PaddedView<LinearLayout>,
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{net::IpAddr, str::FromStr, sync::Arc};
|
||||
|
||||
use cursive::{
|
||||
Printer, Rect, Vec2, View,
|
||||
event::{Event, EventResult},
|
||||
theme::BaseColor,
|
||||
view::{Resizable, ViewWrapper},
|
||||
views::{EditView, LinearLayout, NamedView, ResizedView, SelectView, TextView},
|
||||
Printer, Rect, Vec2, View,
|
||||
};
|
||||
|
||||
use proxmox_installer_common::utils::CidrAddress;
|
||||
|
@ -1,12 +1,12 @@
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
|
||||
use cursive::{
|
||||
Printer, Vec2, View,
|
||||
direction::Direction,
|
||||
event::{AnyCb, Event, EventResult, Key},
|
||||
theme::{ColorStyle, PaletteColor},
|
||||
utils::{markup::StyledString, span::SpannedStr},
|
||||
view::{CannotFocus, IntoBoxedView, Selector, ViewNotFound},
|
||||
Printer, Vec2, View,
|
||||
};
|
||||
|
||||
pub struct TabbedView {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use cursive::{
|
||||
Printer, Rect, Vec2, View,
|
||||
direction::Direction,
|
||||
event::{Event, EventResult},
|
||||
view::{scroll, CannotFocus},
|
||||
Printer, Rect, Vec2, View,
|
||||
view::{CannotFocus, scroll},
|
||||
};
|
||||
|
||||
const HEADER_HEIGHT: usize = 2;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use cursive::{
|
||||
Cursive,
|
||||
view::{Nameable, ViewWrapper},
|
||||
views::{Dialog, NamedView, SelectView},
|
||||
Cursive,
|
||||
};
|
||||
|
||||
use super::FormView;
|
||||
use crate::{system, InstallerState};
|
||||
use crate::{InstallerState, system};
|
||||
use proxmox_installer_common::{
|
||||
options::TimezoneOptions,
|
||||
setup::{KeyboardMapping, LocaleInfo},
|
||||
|
Loading…
Reference in New Issue
Block a user