Skip to content
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
5 changes: 4 additions & 1 deletion examples/dynamic_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use tracing::*;

use std::{env, fmt::Debug};

#[derive(Clone, Debug)]
struct MyStruct {}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();
Expand All @@ -27,7 +30,7 @@ async fn main() -> anyhow::Result<()> {
let (ar, _caps) = kube::discovery::pinned_kind(&client, &gvk).await?;

// Use the full resource info to create an Api with the ApiResource as its DynamicType
let api = Api::<DynamicObject>::all_with(client, &ar);
let api = Api::<MyStruct>::all_with(client, &ar);
let wc = watcher::Config::default();

// Start a metadata or a full resource watch
Expand Down
1 change: 1 addition & 0 deletions kube-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! Everything in this crate is re-exported from [`kube`](https://crates.io/crates/kube)
//! (even with zero features) under [`kube::core`]((https://docs.rs/kube/*/kube/core/index.html)).
#![cfg_attr(docsrs, feature(doc_cfg))]
#![feature(diagnostic_namespace)]
#![deny(missing_docs)]
#![forbid(unsafe_code)]

Expand Down
6 changes: 6 additions & 0 deletions kube-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ impl ResourceScope for DynamicResourceScope {}
/// - `.metadata.resource_version`
///
/// This avoids a bunch of the unnecessary unwrap mechanics for apps.
#[diagnostic::on_unimplemented(
message = "The `kube::Resource` trait is not implemented for `{Self}`",
label = "Is this type a `k8s-openapi` top level Kubernetes type, or a dynamic type created via `CustomResource`",
note = "If this is a CustomResource, please use the generated top level struct (not the spec struct) for `Api`",
note = "If this is a fully typed openapi struct, ensure you use the top-level resource type (e.g. `Pod` over `PodSpec`) for `Api`"
)]
pub trait Resource {
/// Type information for types that do not know their resource information at compile time.
///
Expand Down