treewide: remove code references to known users
This commit is contained in:
parent
b6862c2b49
commit
bf3e5dbcab
|
@ -2,25 +2,18 @@ use crate::systems::System;
|
||||||
|
|
||||||
pub struct ACL {
|
pub struct ACL {
|
||||||
trusted_users: Vec<String>,
|
trusted_users: Vec<String>,
|
||||||
known_users: Vec<String>,
|
|
||||||
repos: Vec<String>,
|
repos: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ACL {
|
impl ACL {
|
||||||
pub fn new(
|
pub fn new(repos: Vec<String>, mut trusted_users: Vec<String>) -> ACL {
|
||||||
repos: Vec<String>,
|
|
||||||
mut trusted_users: Vec<String>,
|
|
||||||
mut known_users: Vec<String>,
|
|
||||||
) -> ACL {
|
|
||||||
trusted_users
|
trusted_users
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.map(|x| *x = x.to_lowercase())
|
.map(|x| *x = x.to_lowercase())
|
||||||
.last();
|
.last();
|
||||||
known_users.iter_mut().map(|x| *x = x.to_lowercase()).last();
|
|
||||||
|
|
||||||
ACL {
|
ACL {
|
||||||
trusted_users,
|
trusted_users,
|
||||||
known_users,
|
|
||||||
repos,
|
repos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,14 +46,6 @@ impl ACL {
|
||||||
.collect()
|
.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 {
|
pub fn can_build_unrestricted(&self, user: &str, repo: &str) -> bool {
|
||||||
if repo.to_lowercase() == "nixos/nixpkgs" {
|
if repo.to_lowercase() == "nixos/nixpkgs" {
|
||||||
self.trusted_users.contains(&user.to_lowercase())
|
self.trusted_users.contains(&user.to_lowercase())
|
||||||
|
|
|
@ -69,7 +69,6 @@ pub struct RunnerConfig {
|
||||||
pub identity: String,
|
pub identity: String,
|
||||||
pub repos: Option<Vec<String>>,
|
pub repos: Option<Vec<String>>,
|
||||||
pub trusted_users: 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
|
/// If true, will create its own queue attached to the build job
|
||||||
/// exchange. This means that builders with this enabled will
|
/// exchange. This means that builders with this enabled will
|
||||||
|
@ -100,10 +99,6 @@ impl Config {
|
||||||
.trusted_users
|
.trusted_users
|
||||||
.clone()
|
.clone()
|
||||||
.expect("fetching config's runner.trusted_users"),
|
.expect("fetching config's runner.trusted_users"),
|
||||||
self.runner
|
|
||||||
.known_users
|
|
||||||
.clone()
|
|
||||||
.expect("fetching config's runner.known_users"),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,11 +107,8 @@ mod tests {
|
||||||
let job: ghevent::PullRequestEvent =
|
let job: ghevent::PullRequestEvent =
|
||||||
serde_json::from_str(&data.to_string()).expect("Should properly deserialize");
|
serde_json::from_str(&data.to_string()).expect("Should properly deserialize");
|
||||||
|
|
||||||
let mut worker = EvaluationFilterWorker::new(acl::ACL::new(
|
let mut worker =
|
||||||
vec!["nixos/nixpkgs".to_owned()],
|
EvaluationFilterWorker::new(acl::ACL::new(vec!["nixos/nixpkgs".to_owned()], vec![]));
|
||||||
vec![],
|
|
||||||
vec![],
|
|
||||||
));
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
worker.consumer(&job),
|
worker.consumer(&job),
|
||||||
|
|
Loading…
Reference in a new issue