From b542789c87e2acdc1de3d52bd0670ace325a87d3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 27 Sep 2020 22:50:31 +0200 Subject: Initial import Signed-off-by: Matthias Beyer --- src/config/mod.rs | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/config/mod.rs (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs new file mode 100644 index 0000000..1c29817 --- /dev/null +++ b/src/config/mod.rs @@ -0,0 +1,81 @@ +use std::path::PathBuf; +use std::fmt::Debug; +use std::ops::Deref; + +use anyhow::Result; +use getset::Getters; +use serde::Deserialize; + +use crate::phase::PhaseName; +use crate::util::EnvironmentVariableName; +use crate::util::docker::ImageName; + +#[derive(Debug, Getters, Deserialize)] +pub struct NotValidatedConfiguration { + #[getset(get = "pub")] + repository: PathBuf, + + #[getset(get = "pub")] + docker: DockerConfig, + + #[getset(get = "pub")] + containers: ContainerConfig, + + #[getset(get = "pub")] + available_phases: Vec, +} + +impl NotValidatedConfiguration { + pub fn validate(self) -> Result { + unimplemented!() + } +} + +#[derive(Debug)] +pub struct Configuration(NotValidatedConfiguration); + +impl Deref for Configuration { + type Target = NotValidatedConfiguration; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + + +#[derive(Debug, Getters, Deserialize)] +pub struct DockerConfig { + + #[getset(get = "pub")] + images: Vec, + + #[getset(get = "pub")] + endpoints: Vec, +} + +#[derive(Debug, Getters, Deserialize)] +pub struct ContainerConfig { + #[getset(get = "pub")] + allowed_env: Vec, +} + + +#[derive(Debug, Getters, Deserialize)] +pub struct Endpoint { + #[getset(get = "pub")] + name: String, + + #[getset(get = "pub")] + uri: String, + + #[getset(get = "pub")] + endpoint_type: EndpointType, +} + +#[derive(Debug, Deserialize, Eq, PartialEq)] +pub enum EndpointType { + Socket, + Http, +} + + -- cgit v1.2.3