Create PipelineRun in response to webhook triggers.
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -22,7 +22,9 @@ use self::crd_pipeline_run::PipelineRun;
|
||||
use self::discovery::discover_matching_push_triggers;
|
||||
use self::discovery::discover_webhook_bridge_config;
|
||||
use self::gitea_client::GiteaClient;
|
||||
use self::hook_push::HookPush;
|
||||
use self::in_repo_config::InRepoConfig;
|
||||
use self::kubernetes::run_pipelines;
|
||||
use self::webhook::hook;
|
||||
use self::webhook::verify_signature;
|
||||
use kube::CustomResourceExt;
|
||||
@@ -32,9 +34,10 @@ mod discovery;
|
||||
mod gitea_client;
|
||||
mod hook_push;
|
||||
mod in_repo_config;
|
||||
mod kubernetes;
|
||||
mod webhook;
|
||||
|
||||
const EXAMPLE_PIPELINE_RUN: &'static str = include_str!("../example_pipeline_run.json");
|
||||
const EXAMPLE_WEBHOOK_PAYLOAD: &'static str = include_str!("../example_webhook_payload.json");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -59,7 +62,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.get_tree(
|
||||
"talexander",
|
||||
"webhook_bridge",
|
||||
"6d3b9e9db82d7857baa114d89efcb1bf470f448d",
|
||||
"b8444344c4821e87a894cd195f8bec39cd501f68",
|
||||
)
|
||||
.await?;
|
||||
let in_repo_config = discover_webhook_bridge_config(&gitea, &repo_tree).await?;
|
||||
@@ -67,14 +70,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
discover_matching_push_triggers(&gitea, &repo_tree, "refs/heads/main", &in_repo_config)
|
||||
.await?;
|
||||
|
||||
// let jobs: Api<PipelineRun> = Api::namespaced(kubernetes_client, "lighthouse");
|
||||
// let jobs: Api<PipelineRun> = Api::default_namespaced(kubernetes_client);
|
||||
// tracing::info!("Using crd: {}", serde_json::to_string(&PipelineRun::crd())?);
|
||||
let webhook_payload: HookPush = serde_json::from_str(EXAMPLE_WEBHOOK_PAYLOAD)?;
|
||||
|
||||
// let test_run: PipelineRun = serde_json::from_str(EXAMPLE_PIPELINE_RUN)?;
|
||||
|
||||
// let pp = PostParams::default();
|
||||
// let created_run = jobs.create(&pp, &test_run).await?;
|
||||
run_pipelines(webhook_payload, pipelines, kubernetes_client).await?;
|
||||
|
||||
// let app = Router::new()
|
||||
// .route("/hook", post(hook))
|
||||
|
||||
Reference in New Issue
Block a user