Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miette test #84

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 163 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"]
elegant-departure = { version = "0.2.1", features = ["tokio"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
anyhow = "1.0.79"
serde = { version = "1.0.195", features = ["derive"] }
k8s-openapi = { version = "0.21.0", features = ["latest"] }
miette = { version = "5.10.0", features = ["fancy"] }

[dependencies.kube]
version = "0.88.0"
Expand Down
8 changes: 5 additions & 3 deletions version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use futures::{future, StreamExt};
use k8s_openapi::api::apps::v1::Deployment;
use kube::runtime::{reflector, watcher, WatchStreamExt};
use kube::{Api, Client, ResourceExt};
use miette::{IntoDiagnostic, Result};
use tracing::{debug, info, warn};

#[derive(serde::Serialize, Clone)]
Expand Down Expand Up @@ -50,19 +51,20 @@ async fn get_versions(State(store): State<Cache>) -> Json<Vec<Entry>> {
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let client = Client::try_default().await?;
let client = Client::try_default().await.into_diagnostic()?;
let api: Api<Deployment> = Api::all(client);

let (reader, writer) = reflector::store();
let watch = reflector(writer, watcher(api, Default::default()))
.default_backoff()
.touched_objects()
.map(|x| x.into_diagnostic())
.for_each(|r| {
future::ready(match r {
Ok(o) => debug!("Saw {} in {}", o.name_any(), o.namespace().unwrap()),
Err(e) => warn!("watcher error: {e}"),
Err(e) => warn!("{e:?}"),
})
});

Expand Down
Loading