diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-25 11:18:33 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-25 11:18:33 +0000 |
commit | 228758b795b3c27d5fd146e380774b29db73432f (patch) | |
tree | 20df497a743e8442f9725c2f5ab552747363a9d1 /src/config.rs | |
parent | a45450a42e4cdcd7f2d5671984c9c7f3945131fd (diff) | |
parent | 00dc4a7a85b32c4337dd3672adec2cbfe3597bfe (diff) | |
download | vmadm-228758b795b3c27d5fd146e380774b29db73432f.tar.gz |
Merge branch 'tilde' into 'main'
test: don't hide clippy output if it's successful
See merge request larswirzenius/vmadm!30
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index 1866971..3f1b341 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,6 @@ //! Tool configuration. +use crate::util::{expand_optional_pathbuf, expand_optional_pathbufs}; use log::debug; use serde::Deserialize; use std::default::Default; @@ -57,11 +58,20 @@ impl Configuration { debug!("reading configuration file {}", filename.display()); let config = fs::read(filename) .map_err(|err| ConfigurationError::ReadError(filename.to_path_buf(), err))?; - let config: Configuration = serde_yaml::from_slice(&config)?; + let mut config: Configuration = serde_yaml::from_slice(&config)?; + config.expand_tildes(); debug!("config: {:#?}", config); Ok(config) } else { Ok(Self::default()) } } + + fn expand_tildes(&mut self) { + expand_optional_pathbuf(&mut self.default_base_image); + expand_optional_pathbuf(&mut self.image_directory); + expand_optional_pathbuf(&mut self.image_directory); + expand_optional_pathbuf(&mut self.ca_key); + expand_optional_pathbufs(&mut self.authorized_keys) + } } |