From d7ffb2b83136db81078659d00ace387534ae3769 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 19:15:01 -0500 Subject: [PATCH] Eligible repo support --- ofborg/src/acl.rs | 8 +++++++- ofborg/src/config.rs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ofborg/src/acl.rs b/ofborg/src/acl.rs index 805d304..90de362 100644 --- a/ofborg/src/acl.rs +++ b/ofborg/src/acl.rs @@ -2,16 +2,22 @@ pub struct ACL { trusted_users: Vec, known_users: Vec, + repos: Vec, } impl ACL { - pub fn new(trusted_users: Vec, known_users: Vec) -> ACL { + pub fn new(repos: Vec, trusted_users: Vec, known_users: Vec) -> ACL { return ACL { trusted_users: trusted_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( &self, user: &str, diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index 0928f7e..ff886a4 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -58,6 +58,7 @@ pub struct LogStorage { #[derive(Serialize, Deserialize, Debug)] pub struct RunnerConfig { pub identity: String, + pub repos: Option>, pub trusted_users: Option>, pub known_users: Option>, } @@ -74,6 +75,9 @@ impl Config { pub fn acl(&self) -> acl::ACL { return acl::ACL::new( + self.runner.repos.clone().expect( + "fetching config's runner.repos", + ), self.runner.trusted_users.clone().expect( "fetching config's runner.trusted_users", ),