config: reuse reserved label and GPT name constants
This commit is contained in:
@@ -128,43 +128,50 @@ pub fn validate(cfg: &Config) -> Result<()> {
|
||||
}
|
||||
|
||||
// Reserved GPT names
|
||||
if cfg.partitioning.esp.gpt_name != "zosboot" {
|
||||
return Err(Error::Validation(
|
||||
"partitioning.esp.gpt_name must be 'zosboot'".into(),
|
||||
));
|
||||
if cfg.partitioning.esp.gpt_name != GPT_NAME_ZOSBOOT {
|
||||
return Err(Error::Validation(format!(
|
||||
"partitioning.esp.gpt_name must be '{}'",
|
||||
GPT_NAME_ZOSBOOT
|
||||
)));
|
||||
}
|
||||
if cfg.partitioning.data.gpt_name != "zosdata" {
|
||||
return Err(Error::Validation(
|
||||
"partitioning.data.gpt_name must be 'zosdata'".into(),
|
||||
));
|
||||
if cfg.partitioning.data.gpt_name != GPT_NAME_ZOSDATA {
|
||||
return Err(Error::Validation(format!(
|
||||
"partitioning.data.gpt_name must be '{}'",
|
||||
GPT_NAME_ZOSDATA
|
||||
)));
|
||||
}
|
||||
if cfg.partitioning.cache.gpt_name != "zoscache" {
|
||||
return Err(Error::Validation(
|
||||
"partitioning.cache.gpt_name must be 'zoscache'".into(),
|
||||
));
|
||||
if cfg.partitioning.cache.gpt_name != GPT_NAME_ZOSCACHE {
|
||||
return Err(Error::Validation(format!(
|
||||
"partitioning.cache.gpt_name must be '{}'",
|
||||
GPT_NAME_ZOSCACHE
|
||||
)));
|
||||
}
|
||||
// BIOS boot name is also 'zosboot' per current assumption
|
||||
if cfg.partitioning.bios_boot.gpt_name != "zosboot" {
|
||||
return Err(Error::Validation(
|
||||
"partitioning.bios_boot.gpt_name must be 'zosboot'".into(),
|
||||
));
|
||||
if cfg.partitioning.bios_boot.gpt_name != GPT_NAME_ZOSBOOT {
|
||||
return Err(Error::Validation(format!(
|
||||
"partitioning.bios_boot.gpt_name must be '{}'",
|
||||
GPT_NAME_ZOSBOOT
|
||||
)));
|
||||
}
|
||||
|
||||
// Reserved filesystem labels
|
||||
if cfg.filesystem.vfat.label != "ZOSBOOT" {
|
||||
return Err(Error::Validation(
|
||||
"filesystem.vfat.label must be 'ZOSBOOT'".into(),
|
||||
));
|
||||
if cfg.filesystem.vfat.label != LABEL_ZOSBOOT {
|
||||
return Err(Error::Validation(format!(
|
||||
"filesystem.vfat.label must be '{}'",
|
||||
LABEL_ZOSBOOT
|
||||
)));
|
||||
}
|
||||
if cfg.filesystem.btrfs.label != "ZOSDATA" {
|
||||
return Err(Error::Validation(
|
||||
"filesystem.btrfs.label must be 'ZOSDATA'".into(),
|
||||
));
|
||||
if cfg.filesystem.btrfs.label != LABEL_ZOSDATA {
|
||||
return Err(Error::Validation(format!(
|
||||
"filesystem.btrfs.label must be '{}'",
|
||||
LABEL_ZOSDATA
|
||||
)));
|
||||
}
|
||||
if cfg.filesystem.bcachefs.label != "ZOSDATA" {
|
||||
return Err(Error::Validation(
|
||||
"filesystem.bcachefs.label must be 'ZOSDATA'".into(),
|
||||
));
|
||||
if cfg.filesystem.bcachefs.label != LABEL_ZOSDATA {
|
||||
return Err(Error::Validation(format!(
|
||||
"filesystem.bcachefs.label must be '{}'",
|
||||
LABEL_ZOSDATA
|
||||
)));
|
||||
}
|
||||
|
||||
// Mount scheme
|
||||
|
||||
10
src/types.rs
10
src/types.rs
@@ -18,6 +18,16 @@
|
||||
use clap::ValueEnum;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Reserved filesystem labels.
|
||||
pub const LABEL_ZOSBOOT: &str = "ZOSBOOT";
|
||||
pub const LABEL_ZOSDATA: &str = "ZOSDATA";
|
||||
pub const LABEL_ZOSCACHE: &str = "ZOSCACHE";
|
||||
|
||||
/// Reserved GPT partition names.
|
||||
pub const GPT_NAME_ZOSBOOT: &str = "zosboot";
|
||||
pub const GPT_NAME_ZOSDATA: &str = "zosdata";
|
||||
pub const GPT_NAME_ZOSCACHE: &str = "zoscache";
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct LoggingConfig {
|
||||
/// Log level: "error" | "warn" | "info" | "debug"
|
||||
|
||||
Reference in New Issue
Block a user