diff options
author | Pietro Albini <pietro@pietroalbini.org> | 2019-07-17 12:06:29 +0200 |
---|---|---|
committer | Pietro Albini <pietro@pietroalbini.org> | 2019-07-17 12:06:29 +0200 |
commit | 9c657f238d9a1354536dcb0a2e89adf5dd6cef4b (patch) | |
tree | a2269b492fe462fb09a09ee89e453a07f4c30b71 /src/validate.rs | |
parent | 732feec5e8db47846ae2fbfe69fbf028090a809d (diff) |
add github teams in the schema and the api
This will allow synchronization tools for GitHub teams to be built. No
teams are currently configured to be synchronized.
Diffstat (limited to 'src/validate.rs')
-rw-r--r-- | src/validate.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/validate.rs b/src/validate.rs index 4c4ebfb..e33f391 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -23,6 +23,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[ validate_rfcbot_labels, validate_rfcbot_exclude_members, validate_team_names, + validate_github_teams, ]; static GITHUB_CHECKS: &[fn(&Data, &GitHubApi, &mut Vec<String>)] = &[validate_github_usernames]; @@ -381,6 +382,34 @@ fn validate_team_names(data: &Data, errors: &mut Vec<String>) { }); } +/// Ensure GitHub teams are unique and in the allowed orgs +fn validate_github_teams(data: &Data, errors: &mut Vec<String>) { + let mut found = HashMap::new(); + let allowed = data.config().allowed_github_orgs(); + wrapper(data.teams(), errors, |team, errors| { + wrapper(team.github_teams().into_iter(), errors, |(org, name), _| { + if !allowed.contains(&*org) { + bail!( + "GitHub organization `{}` isn't allowed (in team `{}`)", + org, + team.name() + ); + } + if let Some(other) = found.insert((org, name), team.name()) { + bail!( + "GitHub team `{}/{}` is defined for both the `{}` and `{}` teams", + org, + name, + team.name(), + other + ); + } + Ok(()) + }); + Ok(()) + }); +} + /// Ensure there are no misspelled GitHub account names fn validate_github_usernames(data: &Data, github: &GitHubApi, errors: &mut Vec<String>) { let people = data |