diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-11-10 10:34:05 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-11-10 10:34:05 +0200 |
commit | 22cc382f9e9aa38f3adad18acd426bf0292bbf00 (patch) | |
tree | 96a392797b77e98d3ce2b26358b9c250db65e1e2 /src/spec.rs | |
parent | 96c3606757750dadfcf31ec5ccd7787292da9273 (diff) | |
download | vmadm-22cc382f9e9aa38f3adad18acd426bf0292bbf00.tar.gz |
feat: check that virtual network names are syntactically correct
Sponsored-by: author
Diffstat (limited to 'src/spec.rs')
-rw-r--r-- | src/spec.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/spec.rs b/src/spec.rs index 4e5665e..e91c044 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -1,7 +1,7 @@ //! Virtual machine specification. use crate::config::Configuration; -use crate::util::expand_tilde; +use crate::util::{check_network_names, expand_tilde}; use log::debug; use serde::{Deserialize, Serialize}; @@ -238,6 +238,10 @@ pub enum SpecificationError { #[error("Failed to read SSH public key file {0}")] SshKeyRead(PathBuf, #[source] std::io::Error), + /// Network name error. + #[error(transparent)] + NetworkNameError(#[from] crate::util::NetworkNameError), + /// Error parsing string as UTF8. #[error(transparent)] FromUtf8Error(#[from] std::string::FromUtf8Error), @@ -300,6 +304,10 @@ impl Specification { false }; + let networks = input.networks(config); + check_network_names(&networks)?; + eprintln!("checked names: {:?}", networks); + let spec = Specification { name: name.to_string(), ssh_keys, @@ -319,7 +327,7 @@ impl Specification { generate_host_certificate: gen_cert, autostart: input.autostart(config), ca_key, - networks: input.networks(config), + networks, }; debug!("specification as with defaults applied: {:#?}", spec); |