Fix clippy lints.
This commit is contained in:
parent
ef195cd4df
commit
cdac8224c6
@ -17,14 +17,22 @@ use serde_json::Value;
|
|||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub(crate) struct PipelineRunSpec {
|
pub(crate) struct PipelineRunSpec {
|
||||||
/// Contents of the Pipeline
|
/// Contents of the Pipeline
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(
|
||||||
pub(crate) pipelineSpec: Option<Value>,
|
rename = "pipelineSpec",
|
||||||
|
default,
|
||||||
|
skip_serializing_if = "Option::is_none"
|
||||||
|
)]
|
||||||
|
pub(crate) pipeline_spec: Option<Value>,
|
||||||
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub(crate) timeouts: Option<Value>,
|
pub(crate) timeouts: Option<Value>,
|
||||||
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(
|
||||||
pub(crate) taskRunTemplate: Option<Value>,
|
rename = "taskRunTemplate",
|
||||||
|
default,
|
||||||
|
skip_serializing_if = "Option::is_none"
|
||||||
|
)]
|
||||||
|
pub(crate) task_run_template: Option<Value>,
|
||||||
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub(crate) workspaces: Option<Value>,
|
pub(crate) workspaces: Option<Value>,
|
||||||
|
@ -4,7 +4,6 @@ use std::path::PathBuf;
|
|||||||
use crate::crd_pipeline_run::PipelineRun;
|
use crate::crd_pipeline_run::PipelineRun;
|
||||||
use crate::gitea_client::GiteaClient;
|
use crate::gitea_client::GiteaClient;
|
||||||
use crate::gitea_client::Tree;
|
use crate::gitea_client::Tree;
|
||||||
use crate::gitea_client::TreeFileReference;
|
|
||||||
use crate::remote_config::RemoteConfig;
|
use crate::remote_config::RemoteConfig;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
@ -16,8 +15,7 @@ pub(crate) async fn discover_webhook_bridge_config(
|
|||||||
let remote_config_reference = repo_tree
|
let remote_config_reference = repo_tree
|
||||||
.files
|
.files
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|file_reference| file_reference.path == ".webhook_bridge/webhook_bridge.toml")
|
.find(|file_reference| file_reference.path == ".webhook_bridge/webhook_bridge.toml")
|
||||||
.next()
|
|
||||||
.ok_or("File not found in remote repo: .webhook_bridge/webhook_bridge.toml.")?;
|
.ok_or("File not found in remote repo: .webhook_bridge/webhook_bridge.toml.")?;
|
||||||
|
|
||||||
let remote_config_contents =
|
let remote_config_contents =
|
||||||
@ -47,8 +45,7 @@ pub(crate) async fn discover_matching_push_triggers<RE: AsRef<str>>(
|
|||||||
let pipeline_template = repo_tree
|
let pipeline_template = repo_tree
|
||||||
.files
|
.files
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|file_reference| Path::new(&file_reference.path) == path_to_source.as_path())
|
.find(|file_reference| Path::new(&file_reference.path) == path_to_source.as_path())
|
||||||
.next()
|
|
||||||
.ok_or("Trigger source not found in remote repo.")?;
|
.ok_or("Trigger source not found in remote repo.")?;
|
||||||
let pipeline_contents = String::from_utf8(gitea.read_file(pipeline_template).await?)?;
|
let pipeline_contents = String::from_utf8(gitea.read_file(pipeline_template).await?)?;
|
||||||
debug!("Pipeline template contents: {}", pipeline_contents);
|
debug!("Pipeline template contents: {}", pipeline_contents);
|
||||||
|
@ -2,7 +2,9 @@ use std::error::Error;
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) enum GiteaClientError {
|
pub(crate) enum GiteaClientError {
|
||||||
|
#[allow(dead_code)]
|
||||||
Static(#[allow(dead_code)] &'static str),
|
Static(#[allow(dead_code)] &'static str),
|
||||||
|
#[allow(dead_code)]
|
||||||
String(#[allow(dead_code)] String),
|
String(#[allow(dead_code)] String),
|
||||||
NoTotalCountHeaderInResponse,
|
NoTotalCountHeaderInResponse,
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ impl GiteaClient {
|
|||||||
owner = owner.as_ref(),
|
owner = owner.as_ref(),
|
||||||
repo = repo.as_ref(),
|
repo = repo.as_ref(),
|
||||||
commit = commit.as_ref(),
|
commit = commit.as_ref(),
|
||||||
page = page.map(|num| format!("&page={}", num)).unwrap_or_else(|| String::new())
|
page = page.map(|num| format!("&page={}", num)).unwrap_or_default()
|
||||||
);
|
);
|
||||||
let response = self
|
let response = self
|
||||||
.http_client
|
.http_client
|
||||||
@ -99,11 +99,18 @@ impl GiteaClient {
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
struct ResponseGetTree {
|
struct ResponseGetTree {
|
||||||
|
#[allow(dead_code)]
|
||||||
sha: String,
|
sha: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
url: String,
|
url: String,
|
||||||
tree: Vec<ResponseObjectReference>,
|
tree: Vec<ResponseObjectReference>,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
truncated: bool,
|
truncated: bool,
|
||||||
page: u64,
|
page: u64,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,10 +118,18 @@ struct ResponseGetTree {
|
|||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
struct ResponseObjectReference {
|
struct ResponseObjectReference {
|
||||||
path: String,
|
path: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
mode: String,
|
mode: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
object_type: String,
|
object_type: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
size: u64,
|
size: u64,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
sha: String,
|
sha: String,
|
||||||
url: String,
|
url: String,
|
||||||
}
|
}
|
||||||
@ -150,7 +165,13 @@ impl TreeFileReference {
|
|||||||
struct ResponseReadFile {
|
struct ResponseReadFile {
|
||||||
content: String,
|
content: String,
|
||||||
encoding: String,
|
encoding: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
url: String,
|
url: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
sha: String,
|
sha: String,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub(crate) async fn run_pipelines(
|
|||||||
name: Some("REPO_URL".to_owned()),
|
name: Some("REPO_URL".to_owned()),
|
||||||
value: pipeline
|
value: pipeline
|
||||||
.clone_uri
|
.clone_uri
|
||||||
.map(|uri| serde_json::Value::String(uri))
|
.map(serde_json::Value::String)
|
||||||
.or_else(|| Some(serde_json::Value::String(hook_repo_url.into_owned()))),
|
.or_else(|| Some(serde_json::Value::String(hook_repo_url.into_owned()))),
|
||||||
});
|
});
|
||||||
param_list.push(PipelineParam {
|
param_list.push(PipelineParam {
|
||||||
|
@ -15,12 +15,8 @@ use tower_http::trace::TraceLayer;
|
|||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
|
||||||
use self::discovery::discover_matching_push_triggers;
|
|
||||||
use self::discovery::discover_webhook_bridge_config;
|
|
||||||
use self::gitea_client::GiteaClient;
|
use self::gitea_client::GiteaClient;
|
||||||
use self::hook_push::HookPush;
|
use self::hook_push::HookPush;
|
||||||
use self::hook_push::PipelineParamters;
|
|
||||||
use self::kubernetes::run_pipelines;
|
|
||||||
use self::webhook::handle_push;
|
use self::webhook::handle_push;
|
||||||
use self::webhook::hook;
|
use self::webhook::hook;
|
||||||
use self::webhook::verify_signature;
|
use self::webhook::verify_signature;
|
||||||
@ -33,9 +29,10 @@ mod kubernetes;
|
|||||||
mod remote_config;
|
mod remote_config;
|
||||||
mod webhook;
|
mod webhook;
|
||||||
|
|
||||||
const EXAMPLE_WEBHOOK_PAYLOAD: &'static str = include_str!("../example_tag_webhook_payload.json");
|
const EXAMPLE_WEBHOOK_PAYLOAD: &str = include_str!("../example_tag_webhook_payload.json");
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
#[allow(clippy::needless_return)]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(
|
.with(
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use axum::async_trait;
|
use axum::async_trait;
|
||||||
use axum::body::Body;
|
use axum::body::Body;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user