Skip to content

Commit

Permalink
treewide: remove code references to known users
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed May 9, 2020
1 parent aa61898 commit 80b12e2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
17 changes: 1 addition & 16 deletions ofborg/src/acl.rs
Expand Up @@ -2,25 +2,18 @@ use crate::systems::System;

pub struct ACL {
trusted_users: Vec<String>,
known_users: Vec<String>,
repos: Vec<String>,
}

impl ACL {
pub fn new(
repos: Vec<String>,
mut trusted_users: Vec<String>,
mut known_users: Vec<String>,
) -> ACL {
pub fn new(repos: Vec<String>, mut trusted_users: Vec<String>) -> ACL {
trusted_users
.iter_mut()
.map(|x| *x = x.to_lowercase())
.last();
known_users.iter_mut().map(|x| *x = x.to_lowercase()).last();

ACL {
trusted_users,
known_users,
repos,
}
}
Expand Down Expand Up @@ -53,14 +46,6 @@ impl ACL {
.collect()
}

pub fn can_build_restricted(&self, user: &str, repo: &str) -> bool {
if repo.to_lowercase() != "nixos/nixpkgs" {
return false;
}

self.known_users.contains(&user.to_lowercase())
}

pub fn can_build_unrestricted(&self, user: &str, repo: &str) -> bool {
if repo.to_lowercase() == "nixos/nixpkgs" {
self.trusted_users.contains(&user.to_lowercase())
Expand Down
5 changes: 0 additions & 5 deletions ofborg/src/config.rs
Expand Up @@ -69,7 +69,6 @@ pub struct RunnerConfig {
pub identity: String,
pub repos: Option<Vec<String>>,
pub trusted_users: Option<Vec<String>>,
pub known_users: Option<Vec<String>>,

/// If true, will create its own queue attached to the build job
/// exchange. This means that builders with this enabled will
Expand Down Expand Up @@ -100,10 +99,6 @@ impl Config {
.trusted_users
.clone()
.expect("fetching config's runner.trusted_users"),
self.runner
.known_users
.clone()
.expect("fetching config's runner.known_users"),
)
}

Expand Down
7 changes: 2 additions & 5 deletions ofborg/src/tasks/evaluationfilter.rs
Expand Up @@ -107,11 +107,8 @@ mod tests {
let job: ghevent::PullRequestEvent =
serde_json::from_str(&data.to_string()).expect("Should properly deserialize");

let mut worker = EvaluationFilterWorker::new(acl::ACL::new(
vec!["nixos/nixpkgs".to_owned()],
vec![],
vec![],
));
let mut worker =
EvaluationFilterWorker::new(acl::ACL::new(vec!["nixos/nixpkgs".to_owned()], vec![]));

assert_eq!(
worker.consumer(&job),
Expand Down

0 comments on commit 80b12e2

Please sign in to comment.