-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🚧 add log as workspace dependency, remove direct print to console
- Loading branch information
1 parent
244d4e7
commit ed32e0a
Showing
15 changed files
with
147 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] | ||
|
||
pub mod comparer; | ||
|
||
pub use comparer::{default_comparer::DefaultComparer, CompareResult, Comparer}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use caps::Capability; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("{cap} is required to run as another user.")] | ||
CapsRequired { cap: Capability }, | ||
#[error("User '{name}' not found")] | ||
UserNotFound { name: String }, | ||
|
||
#[error("I/O error: {0}")] | ||
Io(#[from] std::io::Error), | ||
#[error("{0}")] | ||
CapsError(#[from] caps::errors::CapsError), | ||
} | ||
|
||
pub type Result<T> = std::result::Result<T, Error>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
use anyhow::anyhow; | ||
use once_cell::sync::Lazy; | ||
use std::sync::OnceLock; | ||
|
||
use uzers::{get_user_by_name, User}; | ||
|
||
pub static SUPERVISOR: Lazy<Option<User>> = Lazy::new(|| get_user_by_name("rsjudge-supervisor")); | ||
pub static BUILDER: Lazy<Option<User>> = Lazy::new(|| get_user_by_name("rsjudge-builder")); | ||
pub static RUNNER: Lazy<Option<User>> = Lazy::new(|| get_user_by_name("rsjudge-runner")); | ||
use crate::error::{Error, Result}; | ||
|
||
pub static SUPERVISOR: OnceLock<Option<User>> = OnceLock::new(); | ||
pub static BUILDER: OnceLock<Option<User>> = OnceLock::new(); | ||
pub static RUNNER: OnceLock<Option<User>> = OnceLock::new(); | ||
|
||
pub fn supervisor<'a>() -> anyhow::Result<&'a User> { | ||
pub fn supervisor<'a>() -> Result<&'a User> { | ||
SUPERVISOR | ||
.get_or_init(|| get_user_by_name("rsjudge-supervisor")) | ||
.as_ref() | ||
.ok_or_else(|| anyhow!("User `rsjudge-supervisor` not found")) | ||
.ok_or_else(|| Error::UserNotFound { | ||
name: "rsjudge-supervisor".to_string(), | ||
}) | ||
} | ||
|
||
pub fn builder<'a>() -> anyhow::Result<&'a User> { | ||
pub fn builder<'a>() -> Result<&'a User> { | ||
BUILDER | ||
.get_or_init(|| get_user_by_name("rsjudge-builder")) | ||
.as_ref() | ||
.ok_or_else(|| anyhow!("User `rsjudge-builder` not found")) | ||
.ok_or_else(|| Error::UserNotFound { | ||
name: "rsjudge-builder".to_string(), | ||
}) | ||
} | ||
|
||
pub fn runner<'a>() -> anyhow::Result<&'a User> { | ||
pub fn runner<'a>() -> Result<&'a User> { | ||
RUNNER | ||
.get_or_init(|| get_user_by_name("rsjudge-runner")) | ||
.as_ref() | ||
.ok_or_else(|| anyhow!("User `rsjudge-runner` not found")) | ||
.ok_or_else(|| Error::UserNotFound { | ||
name: "rsjudge-runner".to_string(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.