summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-11-10 10:34:05 +0200
committerLars Wirzenius <liw@liw.fi>2021-11-10 10:34:05 +0200
commit22cc382f9e9aa38f3adad18acd426bf0292bbf00 (patch)
tree96a392797b77e98d3ce2b26358b9c250db65e1e2 /src/config.rs
parent96c3606757750dadfcf31ec5ccd7787292da9273 (diff)
downloadvmadm-22cc382f9e9aa38f3adad18acd426bf0292bbf00.tar.gz
feat: check that virtual network names are syntactically correct
Sponsored-by: author
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index a444d4e..f85ef38 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,6 +1,6 @@
//! Tool configuration.
-use crate::util::{expand_optional_pathbuf, expand_optional_pathbufs};
+use crate::util::{check_network_names, expand_optional_pathbuf, expand_optional_pathbufs};
use log::debug;
use serde::{Deserialize, Serialize};
use std::default::Default;
@@ -46,6 +46,10 @@ pub struct Configuration {
/// Errors from this module.
#[derive(Debug, thiserror::Error)]
pub enum ConfigurationError {
+ /// Network name error.
+ #[error(transparent)]
+ NetworkNameError(#[from] crate::util::NetworkNameError),
+
/// Error reading configuration file.
#[error("couldn't read configuration file {0}")]
ReadError(PathBuf, #[source] std::io::Error),
@@ -67,6 +71,10 @@ impl Configuration {
let config = fs::read(filename)
.map_err(|err| ConfigurationError::ReadError(filename.to_path_buf(), err))?;
let mut config: Configuration = serde_yaml::from_slice(&config)?;
+ eprintln!("raw config: {:#?}", config);
+ if let Some(ref networks) = config.default_networks {
+ check_network_names(networks)?;
+ }
config.expand_tildes()?;
config.fill_in_missing_networks();
debug!("config: {:#?}", config);