diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-25 12:29:44 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-25 13:16:13 +0200 |
commit | 00dc4a7a85b32c4337dd3672adec2cbfe3597bfe (patch) | |
tree | 20df497a743e8442f9725c2f5ab552747363a9d1 /src/spec.rs | |
parent | 7d906d7f5436705ec3f2f3f5c4d8629c79f98fde (diff) | |
download | vmadm-00dc4a7a85b32c4337dd3672adec2cbfe3597bfe.tar.gz |
feat: allow ~/ in config, specification files
Diffstat (limited to 'src/spec.rs')
-rw-r--r-- | src/spec.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/spec.rs b/src/spec.rs index a1d1c2f..a00a5e8 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -1,6 +1,7 @@ //! Virtual machine specification. use crate::config::Configuration; +use crate::util::expand_tilde; use log::debug; use serde::{Deserialize, Serialize}; @@ -293,8 +294,8 @@ impl Specification { ecdsa_host_cert: input.ecdsa_host_cert.clone(), ed25519_host_key: input.ed25519_host_key.clone(), ed25519_host_cert: input.ed25519_host_cert.clone(), - base: input.base_image(config, name)?, - image: input.image(config, name)?, + base: expand_tilde(&input.base_image(config, name)?), + image: expand_tilde(&input.image(config, name)?), image_size_gib: input.image_size_gib(config, name)?, memory_mib: input.memory_mib(config, name)?, cpus: input.cpus(config, name)?, @@ -311,8 +312,9 @@ impl Specification { fn ssh_keys(filenames: &[PathBuf]) -> Result<Vec<String>, SpecificationError> { let mut keys = vec![]; for filename in filenames { - let key = std::fs::read(filename) - .map_err(|e| SpecificationError::SshKeyRead(filename.to_path_buf(), e))?; + let filename = expand_tilde(filename); + let key = + std::fs::read(&filename).map_err(|e| SpecificationError::SshKeyRead(filename, e))?; let key = String::from_utf8(key)?; let key = key.strip_suffix("\n").or(Some(&key)).unwrap(); keys.push(key.to_string()); |