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
use super::Result;
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct ConfigMap {
pub mount: String,
pub files: Vec<ConfigMappedFile>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct ConfigMappedFile {
pub name: String,
pub dest: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
impl ConfigMap {
pub fn verify(&self) -> Result<()> {
if self.mount == "" || self.mount.starts_with('~') {
bail!("Invalid mountpath '{}'", self.mount)
}
if !self.mount.ends_with('/') {
bail!("Mount path '{}' must end with a slash", self.mount);
}
for f in &self.files {
if !f.name.ends_with(".j2") {
bail!("Only supporting templated config files atm")
}
if f.dest == "" {
bail!("Empty mount destination for {}", f.name);
}
}
Ok(())
}
}