Creating an example PipelineRun.
This commit is contained in:
24
src/crd_pipeline_run.rs
Normal file
24
src/crd_pipeline_run.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use kube::CustomResource;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
|
||||
/// A single execution of a Pipeline.
|
||||
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
|
||||
#[kube(
|
||||
group = "tekton.dev",
|
||||
version = "v1beta1",
|
||||
kind = "PipelineRun",
|
||||
singular = "pipelinerun",
|
||||
plural = "pipelineruns"
|
||||
)]
|
||||
#[kube(namespaced)]
|
||||
pub struct PipelineRunSpec {
|
||||
/// Contents of the Pipeline
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub pipelineSpec: Option<Value>,
|
||||
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub timeout: Option<String>,
|
||||
}
|
||||
16
src/main.rs
16
src/main.rs
@@ -7,6 +7,8 @@ use axum::routing::get;
|
||||
use axum::routing::post;
|
||||
use axum::Json;
|
||||
use axum::Router;
|
||||
use kube::api::PostParams;
|
||||
use kube::Api;
|
||||
use kube::Client;
|
||||
use serde::Serialize;
|
||||
use tokio::signal;
|
||||
@@ -15,12 +17,17 @@ use tower_http::trace::TraceLayer;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
use self::crd_pipeline_run::PipelineRun;
|
||||
use self::webhook::hook;
|
||||
use self::webhook::verify_signature;
|
||||
use kube::CustomResourceExt;
|
||||
|
||||
mod crd_pipeline_run;
|
||||
mod hook_push;
|
||||
mod webhook;
|
||||
|
||||
const EXAMPLE_PIPELINE_RUN: &'static str = include_str!("../example_pipeline_run.json");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tracing_subscriber::registry()
|
||||
@@ -36,6 +43,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await
|
||||
.expect("Set KUBECONFIG to a valid kubernetes config.");
|
||||
|
||||
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 test_run: PipelineRun = serde_json::from_str(EXAMPLE_PIPELINE_RUN)?;
|
||||
|
||||
let pp = PostParams::default();
|
||||
let created_run = jobs.create(&pp, &test_run).await?;
|
||||
|
||||
let app = Router::new()
|
||||
.route("/hook", post(hook))
|
||||
.layer(middleware::from_fn(verify_signature))
|
||||
|
||||
Reference in New Issue
Block a user