summaryrefslogtreecommitdiff
path: root/makima/src/orchestration/verifier.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/orchestration/verifier.rs')
-rw-r--r--makima/src/orchestration/verifier.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/makima/src/orchestration/verifier.rs b/makima/src/orchestration/verifier.rs
index e98da50..bc29e47 100644
--- a/makima/src/orchestration/verifier.rs
+++ b/makima/src/orchestration/verifier.rs
@@ -290,6 +290,18 @@ pub enum VerifierError {
Io(#[from] std::io::Error),
}
+/// Information about a verifier for serialization and database storage.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct VerifierInfo {
+ pub name: String,
+ pub verifier_type: String,
+ pub command: String,
+ pub working_directory: Option<String>,
+ pub detect_files: Vec<String>,
+ pub weight: f64,
+ pub required: bool,
+}
+
/// Verifier trait for pluggable verification implementations.
#[async_trait]
pub trait Verifier: Send + Sync {
@@ -299,6 +311,9 @@ pub trait Verifier: Send + Sync {
/// Get the type of this verifier.
fn verifier_type(&self) -> VerifierType;
+ /// Get serializable info about this verifier.
+ fn info(&self) -> VerifierInfo;
+
/// Check if this verifier is applicable to the given repository.
async fn is_applicable(&self, repo_path: &Path) -> bool;
@@ -393,6 +408,18 @@ impl Verifier for CommandVerifier {
self.verifier_type.clone()
}
+ fn info(&self) -> VerifierInfo {
+ VerifierInfo {
+ name: self.name.clone(),
+ verifier_type: self.verifier_type.as_str().to_string(),
+ command: self.command.clone(),
+ working_directory: self.working_dir.clone(),
+ detect_files: self.applicable_patterns.clone(),
+ weight: 1.0,
+ required: self.required,
+ }
+ }
+
async fn is_applicable(&self, repo_path: &Path) -> bool {
if self.applicable_patterns.is_empty() {
return true;