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;
struct MySourceSpec { #[serde(flatten)] source_spec: SourceSpec, }
struct MySourceStatus {
#[serde(flatten)]
source_status: SourceStatus
struct Data { client: kube::Client, }
async fn reconcile(myresource: Arc
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!