]> git.proxmox.com Git - pve-installer.git/commitdiff
auto installer: rename fetch mode type and included variant
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Apr 2024 13:11:11 +0000 (15:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Apr 2024 13:18:18 +0000 (15:18 +0200)
This is not a installation mode but rather tells us where to fetch the
answer file from.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-auto-install-assistant/src/main.rs
proxmox-auto-installer/src/utils.rs
proxmox-fetch-answer/src/main.rs

index ca3839c6a939b74f26d404465bcf856dfd63ce42..a8b28952435cdfb56e362a23ef9477ddea0f07d7 100644 (file)
@@ -16,7 +16,7 @@ use proxmox_auto_installer::{
     answer::FilterMatch,
     sysinfo::SysInfo,
     utils::{
-        get_matched_udev_indexes, get_nic_list, get_single_udev_index, AutoInstMode,
+        get_matched_udev_indexes, get_nic_list, get_single_udev_index, FetchAnswerFrom,
         AutoInstSettings, HttpOptions,
     },
 };
@@ -126,7 +126,7 @@ struct CommandPrepareISO {
 
     /// Where the automatic installer should fetch the answer file from.
     #[arg(long, value_enum)]
-    fetch_from: AutoInstMode,
+    fetch_from: FetchAnswerFrom,
 
     /// Include the specified answer file in the ISO. Requires the '--fetch-from'  parameter
     /// to be set to 'iso'.
@@ -281,7 +281,7 @@ fn show_system_info(_args: &CommandSystemInfo) -> Result<()> {
 fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
     check_prepare_requirements(args)?;
 
-    if args.fetch_from == AutoInstMode::Included {
+    if args.fetch_from == FetchAnswerFrom::Iso {
         if args.answer_file.is_none() {
             bail!("Missing path to answer file needed for 'direct' install mode.");
         }
@@ -291,7 +291,7 @@ fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
         if args.url.is_some() {
             bail!("No URL needed for direct install mode. Drop the parameter!");
         }
-    } else if args.fetch_from == AutoInstMode::Partition {
+    } else if args.fetch_from == FetchAnswerFrom::Partition {
         if args.cert_fingerprint.is_some() {
             bail!(
                 "No certificate fingerprint needed for partition install mode. Drop the parameter!"
@@ -301,7 +301,7 @@ fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
             bail!("No URL needed for partition install mode. Drop the parameter!");
         }
     }
-    if args.answer_file.is_some() && args.fetch_from != AutoInstMode::Included {
+    if args.answer_file.is_some() && args.fetch_from != FetchAnswerFrom::Iso {
         bail!("Set '-i', '--install-mode' to 'included' to place the answer file directly in the ISO.");
     }
 
@@ -358,9 +358,9 @@ fn final_iso_location(args: &CommandPrepareISO) -> PathBuf {
         return specified;
     }
     let mut suffix: String = match args.fetch_from {
-        AutoInstMode::Http => "auto-from-http",
-        AutoInstMode::Included => "auto-from-iso",
-        AutoInstMode::Partition => "auto-from-partition",
+        FetchAnswerFrom::Http => "auto-from-http",
+        FetchAnswerFrom::Iso => "auto-from-iso",
+        FetchAnswerFrom::Partition => "auto-from-partition",
     }
     .into();
 
index e1ae676777a47026b9a3bfb9db7d4ca917490725..b6df6c2ccb64aa52d1ff123f6e1ee888185a90cb 100644 (file)
@@ -69,8 +69,8 @@ pub fn get_single_udev_index(
 
 #[derive(Deserialize, Serialize, Debug, Clone, ValueEnum, PartialEq)]
 #[serde(rename_all = "lowercase", deny_unknown_fields)]
-pub enum AutoInstMode {
-    Included,
+pub enum FetchAnswerFrom {
+    Iso,
     Http,
     Partition,
 }
@@ -86,7 +86,7 @@ pub struct HttpOptions {
 #[derive(Deserialize, Serialize, Debug)]
 #[serde(rename_all = "lowercase", deny_unknown_fields)]
 pub struct AutoInstSettings {
-    pub mode: AutoInstMode,
+    pub mode: FetchAnswerFrom,
     #[serde(default)]
     pub http: HttpOptions,
 }
index 868099a059255e196d2270f0228462fc93bac824..a0a4d010636113f250400a78f101088766965152 100644 (file)
@@ -6,7 +6,7 @@ use log::{error, info, LevelFilter};
 
 use proxmox_auto_installer::{
     log::AutoInstLogger,
-    utils::{AutoInstMode, AutoInstSettings},
+    utils::{FetchAnswerFrom, AutoInstSettings},
 };
 
 use fetch_plugins::{http::FetchFromHTTP, partition::FetchFromPartition};
@@ -26,18 +26,18 @@ pub fn init_log() -> Result<()> {
 fn fetch_answer(install_settings: &AutoInstSettings) -> Result<String> {
     info!("Fetching answer file in mode {:?}:", &install_settings.mode);
     match install_settings.mode {
-        AutoInstMode::Included => {
+        FetchAnswerFrom::Iso => {
             let answer_path = PathBuf::from("/cdrom/answer.toml");
             match fs::read_to_string(answer_path) {
                 Ok(answer) => return Ok(answer),
                 Err(err) => info!("Fetching answer file from ISO failed: {err}"),
             }
         }
-        AutoInstMode::Partition => match FetchFromPartition::get_answer() {
+        FetchAnswerFrom::Partition => match FetchFromPartition::get_answer() {
             Ok(answer) => return Ok(answer),
             Err(err) => info!("Fetching answer file from partition failed: {err}"),
         },
-        AutoInstMode::Http => match FetchFromHTTP::get_answer(&install_settings.http) {
+        FetchAnswerFrom::Http => match FetchFromHTTP::get_answer(&install_settings.http) {
             Ok(answer) => return Ok(answer),
             Err(err) => info!("Fetching answer file via HTTP failed: {err}"),
         },