diff --git a/src/config.rs b/src/config.rs index 0ba78b8b..20a48958 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,25 +4,26 @@ use crate::image; use failure::Error; use quicli::prelude::*; +use std::collections::BTreeMap; use std::fs::File; use std::path; #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum Shell { +pub(crate) enum Shell { Shell(String), TwoShell { inner: String, outer: String }, } impl Shell { - pub fn inner_shell(&self) -> &str { + pub(crate) fn inner_shell(&self) -> &str { match self { Shell::Shell(s) => s, Shell::TwoShell { inner: s, outer: _ } => s, } } - pub fn outer_shell(&self) -> &str { + pub(crate) fn outer_shell(&self) -> &str { match self { Shell::Shell(s) => s, Shell::TwoShell { inner: _, outer: s } => s, @@ -30,6 +31,13 @@ impl Shell { } } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub(crate) struct Volume { + #[serde(default = "default_to_false")] + shared: bool, + mount: path::PathBuf, +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub(crate) struct FlokiConfig { @@ -48,6 +56,8 @@ pub(crate) struct FlokiConfig { pub(crate) dind: bool, #[serde(default = "default_to_false")] pub(crate) forward_user: bool, + #[serde(default = "BTreeMap::new")] + pub(crate) volumes: BTreeMap, } impl FlokiConfig { @@ -83,6 +93,12 @@ impl FlokiConfig { } } + debug!( + "Parsed '{}' into configuration: {:?}", + file.display(), + &config + ); + Ok(config) } } diff --git a/src/verify.rs b/src/verify.rs index 682a8a0a..657cda8c 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -16,6 +16,8 @@ mod test { use crate::config::Shell::Shell; use crate::image::Image::Name; + use std::collections::BTreeMap; + fn get_test_config(docker_switches: Vec) -> FlokiConfig { FlokiConfig { image: Name("foo".into()), @@ -26,6 +28,7 @@ mod test { forward_ssh_agent: false, dind: false, forward_user: false, + volumes: BTreeMap::new(), } }