main: Move default values preparation into a dedicated function

This brings more modularity to the code, which will be helpful when we
will later test the CLI and OpenAPI generate the same VmConfig output.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-12-13 08:34:39 +01:00
parent 9c3a7ddcc9
commit 17a167dbb6

View File

@ -62,6 +62,14 @@ impl log::Log for Logger {
fn flush(&self) {}
}
fn prepare_default_values() -> (String, String, String) {
let default_vcpus = format! {"boot={}", config::DEFAULT_VCPUS};
let default_memory = format! {"size={}M", config::DEFAULT_MEMORY_MB};
let default_rng = format! {"src={}", config::DEFAULT_RNG_SOURCE};
(default_vcpus, default_memory, default_rng)
}
fn create_app<'a, 'b>(
default_vcpus: &'a str,
default_memory: &'a str,
@ -269,9 +277,7 @@ fn main() {
}
}
let default_vcpus = format! {"boot={}", config::DEFAULT_VCPUS};
let default_memory = format! {"size={}M", config::DEFAULT_MEMORY_MB};
let default_rng = format! {"src={}", config::DEFAULT_RNG_SOURCE};
let (default_vcpus, default_memory, default_rng) = prepare_default_values();
let cmd_arguments = create_app(
&default_vcpus,