Last active
May 5, 2022 20:17
-
-
Save chmouel/cb398155eae141725a2e062f27542208 to your computer and use it in GitHub Desktop.
Querying tekton objects with Rust, dynamic clients and tokio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "tekton-rs" | |
version = "0.1.0" | |
authors = ["Chmouel Boudjnah <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
kube = { version = "0.71.0", features = ["runtime", "derive"] } | |
k8s-openapi = { version = "0.14.0", features = ["v1_23"] } | |
tokio = { version = "1.14.0", features = ["full"] } | |
anyhow = "1.0.44" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::Ok; | |
use kube::{ | |
api::ListParams, | |
core::{DynamicObject, GroupVersionKind}, | |
discovery, Api, Client, | |
}; | |
#[tokio::main] | |
async fn main() -> anyhow::Result<()> { | |
let client = Client::try_default().await?; | |
let namespace = std::env::var("NAMESPACE").unwrap_or_else(|_| "test".into()); | |
let gvk = GroupVersionKind::gvk("tekton.dev", "v1beta1", "PipelineRun"); | |
let (ar, _caps) = discovery::pinned_kind(&client, &gvk).await?; | |
let dynapi = Api::<DynamicObject>::namespaced_with(client, &namespace, &ar); | |
let prs = dynapi.list(&ListParams::default()).await?; | |
dbg!(prs.items); | |
let pr = dynapi.get("pr-test").await?; | |
let status = pr.data["status"].as_object().unwrap(); | |
dbg!(status); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment