Knative

A Rust implementation of Knative and Knative Eventing custom resource defintions and objects, leveraging kube-rs.

This implementation is incomplete and should be considered pre-alpha. It contains only a small subset of the full specification.

Currently, you can use this crate to manage the status of a custom event source CustomResource in accordance with knative's expectations.

```rust use schemars::JsonSchema; use serde::{Serialize, Deserialize}; use kube::{Api, CustomResource, Resource, ResourceExt}; use kube::runtime::controller::{Action, Context}; use knative::source_types::{ SourceSpec, SourceStatus, SourceCondition, SinkManager, }; use std::sync::Arc;

[derive(Serialize, Deserialize, CustomResource, Clone, Debug, JsonSchema)]

[kube(group = "mysource.dev", version = "v1", kind = "MySource", status = "MySourceStatus", namespaced)]

struct MySourceSpec { #[serde(flatten)] source_spec: SourceSpec, }

[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]

struct MySourceStatus { #[serde(flatten)] source_status: SourceStatus, }

[derive(Clone)]

struct Data { client: kube::Client, }

async fn reconcile(myresource: Arc, ctx: Context) -> Result { let client = ctx.getref().client.clone(); let api = Api::::namespaced( client.clone(), myresource.namespace().asref().unwrap() ); let mut resource = api.getstatus(&myresource.name()).await?;

if let Some(ref mut status) = resource.status {
    status.source_status.mark_sink("http://hardcoded-sink".parse().unwrap());

    // ...set the K_SINK environment variable on the receive-adapter that this controller manages

    // ...patch the new status with the api
}

Ok(Action::requeue(std::time::Duration::from_secs( 60 * 60)))

} ```

Additionaly reference usage of this crate is currently WIP!