Eligible repo support

This commit is contained in:
Graham Christensen 2018-02-23 19:15:01 -05:00
parent 2745eb85b1
commit d7ffb2b831
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 11 additions and 1 deletions

View file

@ -2,16 +2,22 @@
pub struct ACL { pub struct ACL {
trusted_users: Vec<String>, trusted_users: Vec<String>,
known_users: Vec<String>, known_users: Vec<String>,
repos: Vec<String>,
} }
impl ACL { impl ACL {
pub fn new(trusted_users: Vec<String>, known_users: Vec<String>) -> ACL { pub fn new(repos: Vec<String>, trusted_users: Vec<String>, known_users: Vec<String>) -> ACL {
return ACL { return ACL {
trusted_users: trusted_users, trusted_users: trusted_users,
known_users: known_users, known_users: known_users,
repos: repos,
}; };
} }
pub fn is_repo_eligible(&self, name: &str) -> bool {
self.repos.contains(&name.to_lowercase())
}
pub fn build_job_destinations_for_user_repo( pub fn build_job_destinations_for_user_repo(
&self, &self,
user: &str, user: &str,

View file

@ -58,6 +58,7 @@ pub struct LogStorage {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct RunnerConfig { pub struct RunnerConfig {
pub identity: String, pub identity: String,
pub repos: Option<Vec<String>>,
pub trusted_users: Option<Vec<String>>, pub trusted_users: Option<Vec<String>>,
pub known_users: Option<Vec<String>>, pub known_users: Option<Vec<String>>,
} }
@ -74,6 +75,9 @@ impl Config {
pub fn acl(&self) -> acl::ACL { pub fn acl(&self) -> acl::ACL {
return acl::ACL::new( return acl::ACL::new(
self.runner.repos.clone().expect(
"fetching config's runner.repos",
),
self.runner.trusted_users.clone().expect( self.runner.trusted_users.clone().expect(
"fetching config's runner.trusted_users", "fetching config's runner.trusted_users",
), ),