summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-07 17:07:20 +0200
committerLars Wirzenius <liw@liw.fi>2021-03-07 17:07:20 +0200
commit1e8ba95def26de67f8fd618549d6b8f80a14ddd8 (patch)
treedc4916152d7c1f488174a7297863e89bad8daa03 /src/config.rs
parent54f0cba69a023ccf0b781dd76a2b370bf6400585 (diff)
downloadvmadm-1e8ba95def26de67f8fd618549d6b8f80a14ddd8.tar.gz
doc: add doc comments to crate
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());