diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-09-27 22:50:31 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2020-10-12 15:14:17 +0200 |
commit | b542789c87e2acdc1de3d52bd0670ace325a87d3 (patch) | |
tree | 13e3817c59f1db797b71f8c13c07a4a826c6b651 /src/config |
Initial import
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/mod.rs | 81 |
1 files changed, 81 insertions, 0 deletions
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<PhaseName>, +} + +impl NotValidatedConfiguration { + pub fn validate(self) -> Result<Configuration> { + 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<ImageName>, + + #[getset(get = "pub")] + endpoints: Vec<Endpoint>, +} + +#[derive(Debug, Getters, Deserialize)] +pub struct ContainerConfig { + #[getset(get = "pub")] + allowed_env: Vec<EnvironmentVariableName>, +} + + +#[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, +} + + |