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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use super::Result;
use crate::structs::SlackChannel;
use std::{
collections::BTreeMap,
path::{Path, PathBuf},
};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Person {
pub name: String,
pub github: Option<String>,
pub slack: String,
pub email: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Squad {
pub name: String,
pub members: Vec<String>,
#[serde(default)]
pub owners: Vec<String>,
pub github: GithubTeams,
pub slack: SlackSet,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tribe {
pub name: String,
pub squads: Vec<String>,
pub github: Option<GithubTeams>,
pub slack: Option<SlackSet>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Owners {
pub people: BTreeMap<String, Person>,
pub squads: BTreeMap<String, Squad>,
pub tribes: BTreeMap<String, Tribe>,
}
impl Owners {
pub fn read() -> Result<Owners> {
let pwd = Path::new(".");
Owners::read_from(&pwd.to_path_buf())
}
pub fn read_from(pwd: &PathBuf) -> Result<Owners> {
use std::fs;
let mpath = pwd.join("teams.yml");
trace!("Using teams file in {}", mpath.display());
if !mpath.exists() {
bail!("Teams file {} does not exist", mpath.display())
}
let data = fs::read_to_string(&mpath)?;
let res = serde_yaml::from_str(&data)?;
Ok(res)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SlackSet {
pub internal: Option<SlackChannel>,
pub support: Option<SlackChannel>,
pub notifications: Option<SlackChannel>,
pub alerts: Option<SlackChannel>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GithubTeams {
pub team: String,
pub admins: Option<String>,
}