summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 9f99655..9894f45 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,31 +1,54 @@
+//! Tool configuration.
+
use log::debug;
use serde::Deserialize;
use std::default::Default;
use std::fs;
use std::path::{Path, PathBuf};
+/// Configuration from configuration file.
#[derive(Default, Debug, Deserialize)]
pub struct Configuration {
+ /// Base image, if provided.
pub default_base_image: Option<PathBuf>,
+
+ /// Default size of new VM image, in GiB.
pub default_image_gib: Option<u64>,
+
+ /// Default memory to give to new VM, in MiB.
pub default_memory_mib: Option<u64>,
+
+ /// Default number of CPUs for a new VM.
pub default_cpus: Option<u64>,
+
+ /// Should host certificates be generated for new VMs?
pub default_generate_host_certificate: Option<bool>,
+
+ /// Directory where new VM images should be created, if given.
pub image_directory: Option<PathBuf>,
+
+ /// List of path names of SSH public keys to put into the default
+ /// user's `authorized_keys` file.
pub authorized_keys: Option<Vec<PathBuf>>,
+
+ /// Path name to SSH CA key for creating SSH host certificates.
pub ca_key: Option<PathBuf>,
}
+/// Errors from this module.
#[derive(Debug, thiserror::Error)]
pub enum ConfigurationError {
+ /// I/O error.
#[error(transparent)]
IoError(#[from] std::io::Error),
+ /// YAML parsing error.
#[error(transparent)]
YamlError(#[from] serde_yaml::Error),
}
impl Configuration {
+ /// Read configuration from named file.
pub fn from_file(filename: &Path) -> Result<Self, ConfigurationError> {
if filename.exists() {
debug!("reading configuration file {}", filename.display());