1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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> {
Ok(Configuration(self)) // TODO: Implement properly
}
}
#[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,
}
|